From e9f35e891886e0a7d62e517c96c1daa8e9877cee Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Thu, 15 Jul 2004 14:12:20 +0000 Subject: Backport of 1.26: CFStringGetUnicode() returned an extra null character at the end of the string. fixed. --- Mac/Modules/cf/_CFmodule.c | 7 +------ Mac/Modules/cf/cfsupport.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c index d6dba45..7bb56e8 100644 --- a/Mac/Modules/cf/_CFmodule.c +++ b/Mac/Modules/cf/_CFmodule.c @@ -5,12 +5,7 @@ -#ifdef _WIN32 -#include "pywintoolbox.h" -#else -#include "macglue.h" #include "pymactoolbox.h" -#endif /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ @@ -2001,7 +1996,7 @@ static PyObject *CFStringRefObj_CFStringGetUnicode(CFStringRefObject *_self, PyO range.length = size; if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); - _res = (PyObject *)PyUnicode_FromUnicode(data, size); + _res = (PyObject *)PyUnicode_FromUnicode(data, size-1); free(data); return _res; diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index f27c58b..9c2880e 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -558,7 +558,7 @@ range.location = 0; range.length = size; if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(_self->ob_itself, range, data); -_res = (PyObject *)PyUnicode_FromUnicode(data, size); +_res = (PyObject *)PyUnicode_FromUnicode(data, size-1); free(data); return _res; """ -- cgit v0.12