|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH] C extension fails to build on Python 2.5 because of PyUnicode_FromFormatHello,
Cheetah C extension doesn't build on Python <= 2.5 because of PyUnicode_FromFormat() being only available on Python >= 2.6. I have attached a patch to make it build on Python 2.5 and inferior versions. It builds without warning on Python 2.5, 2.6 and 3.1 and I can import _namemapper on all these versions, moreover all the tests passed. Hope the patch is good as I'm not really familiar with Python C/API. BTW, my question may be silly but I'm wondering why `newExcValue' reference returned by PyUnicode_FromFormat() (wrapInternalNotFoundException() function) is never DECREF whereas it is in setNotFoundException() function for `exceptionStr'. Just curious ;)... Cheers, Arnaud Fontaine Description: C extension fails to build because of PyUnicode_FromFormat only available on Python >= 2.6 Author: Arnaud Fontaine <arnau@...> --- a/cheetah/c/cheetah.h 2010-02-08 04:17:23.000000000 +0000 +++ b/cheetah/c/cheetah.h 2010-03-30 22:42:49.000000000 +0100 @@ -37,6 +37,9 @@ #if PY_MAJOR_VERSION >= 3 #define IS_PYTHON3 +#elif PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 5 +/* PyUnicode_FromFormat is only available on Python >= 2.6 */ +#define IS_PYTHON25_OR_LESS #endif #define TRUE 1 --- a/cheetah/c/_namemapper.c 2010-02-08 04:17:23.000000000 +0000 +++ b/cheetah/c/_namemapper.c 2010-03-30 22:40:01.000000000 +0100 @@ -35,7 +35,13 @@ static void setNotFoundException(char *key, PyObject *namespace) { PyObject *exceptionStr = NULL; +#ifdef IS_PYTHON25_OR_LESS + exceptionStr = Py_BuildValue("s", "cannot find '"); + PyString_ConcatAndDel(&exceptionStr, Py_BuildValue("s", key)); + PyString_ConcatAndDel(&exceptionStr, Py_BuildValue("s", "'")); +#else exceptionStr = PyUnicode_FromFormat("cannot find \'%s\'", key); +#endif PyErr_SetObject(NotFound, exceptionStr); Py_XDECREF(exceptionStr); } @@ -58,8 +64,15 @@ if (isAlreadyWrapped != NULL) { if (PyLong_AsLong(isAlreadyWrapped) == -1) { +#ifdef IS_PYTHON25_OR_LESS + newExcValue = Py_BuildValue("U", excValue); + PyString_ConcatAndDel(&newExcValue, Py_BuildValue("s", "while searching for '")); + PyString_ConcatAndDel(&newExcValue, Py_BuildValue("s", fullName)); + PyString_ConcatAndDel(&newExcValue, Py_BuildValue("s", "'")); +#else newExcValue = PyUnicode_FromFormat("%U while searching for \'%s\'", excValue, fullName); +#endif } Py_DECREF(isAlreadyWrapped); } ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
Re: [PATCH] C extension fails to build on Python 2.5 because of PyUnicode_FromFormatOn Wed, 31 Mar 2010, Arnaud Fontaine wrote: > Hello, > > Cheetah C extension doesn't build on Python <= 2.5 because of > PyUnicode_FromFormat() being only available on Python >= 2.6. I have > attached a patch to make it build on Python 2.5 and inferior > versions. It builds without warning on Python 2.5, 2.6 and 3.1 and I can > import _namemapper on all these versions, moreover all the tests > passed. Hope the patch is good as I'm not really familiar with Python > C/API. Aha, good catch Arnaud, I had experienced a similar quirk when I ported another C-extension that I maintain to run on Python 2.4 - 3.1, I'll squeeze an update out tonight or tomorrow :) > > BTW, my question may be silly but I'm wondering why `newExcValue' > reference returned by PyUnicode_FromFormat() > (wrapInternalNotFoundException() function) is never DECREF whereas it is > in setNotFoundException() function for `exceptionStr'. Just curious > ;)... > > Cheers, > Arnaud Fontaine > > Description: C extension fails to build because of PyUnicode_FromFormat only available on Python >= 2.6 > Author: Arnaud Fontaine <arnau@...> > > --- a/cheetah/c/cheetah.h 2010-02-08 04:17:23.000000000 +0000 > +++ b/cheetah/c/cheetah.h 2010-03-30 22:42:49.000000000 +0100 > @@ -37,6 +37,9 @@ > > #if PY_MAJOR_VERSION >= 3 > #define IS_PYTHON3 > +#elif PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 5 > +/* PyUnicode_FromFormat is only available on Python >= 2.6 */ > +#define IS_PYTHON25_OR_LESS > #endif > > #define TRUE 1 > --- a/cheetah/c/_namemapper.c 2010-02-08 04:17:23.000000000 +0000 > +++ b/cheetah/c/_namemapper.c 2010-03-30 22:40:01.000000000 +0100 > @@ -35,7 +35,13 @@ > static void setNotFoundException(char *key, PyObject *namespace) > { > PyObject *exceptionStr = NULL; > +#ifdef IS_PYTHON25_OR_LESS > + exceptionStr = Py_BuildValue("s", "cannot find '"); > + PyString_ConcatAndDel(&exceptionStr, Py_BuildValue("s", key)); > + PyString_ConcatAndDel(&exceptionStr, Py_BuildValue("s", "'")); > +#else > exceptionStr = PyUnicode_FromFormat("cannot find \'%s\'", key); > +#endif > PyErr_SetObject(NotFound, exceptionStr); > Py_XDECREF(exceptionStr); > } > @@ -58,8 +64,15 @@ > > if (isAlreadyWrapped != NULL) { > if (PyLong_AsLong(isAlreadyWrapped) == -1) { > +#ifdef IS_PYTHON25_OR_LESS > + newExcValue = Py_BuildValue("U", excValue); > + PyString_ConcatAndDel(&newExcValue, Py_BuildValue("s", "while searching for '")); > + PyString_ConcatAndDel(&newExcValue, Py_BuildValue("s", fullName)); > + PyString_ConcatAndDel(&newExcValue, Py_BuildValue("s", "'")); > +#else > newExcValue = PyUnicode_FromFormat("%U while searching for \'%s\'", > excValue, fullName); > +#endif > } > Py_DECREF(isAlreadyWrapped); > } > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Cheetahtemplate-discuss mailing list > Cheetahtemplate-discuss@... > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss Cheers, -R. Tyler Ballance -------------------------------------- Jabber: rtyler@... GitHub: http://github.com/rtyler Twitter: http://twitter.com/agentdero Blog: http://unethicalblogger.com ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
Re: [PATCH] C extension fails to build on Python 2.5 because of PyUnicode_FromFormatHi,
> Aha, good catch Arnaud, I had experienced a similar quirk when I > ported another C-extension that I maintain to run on Python 2.4 - > 3.1, I'll squeeze an update out tonight or tomorrow :) Does the patch look alright? I have already uploaded a Debian package of python-cheetah 2.4.2.1 which includes this patch. So don't worry about the update ;), especially because I seem to be the only one to report such issue. >> BTW, my question may be silly but I'm wondering why `newExcValue' >> reference returned by PyUnicode_FromFormat() >> (wrapInternalNotFoundException() function) is never DECREF >> whereas it is in setNotFoundException() function for >> `exceptionStr'. Just curious ;)... Any thoughts about that? ;) Cheers, Arnaud ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
Re: [PATCH] C extension fails to build on Python 2.5 because of PyUnicode_FromFormatOn Wed, 31 Mar 2010, Arnaud Fontaine wrote: > Hi, > > > Aha, good catch Arnaud, I had experienced a similar quirk when I > > ported another C-extension that I maintain to run on Python 2.4 - > > 3.1, I'll squeeze an update out tonight or tomorrow :) > > Does the patch look alright? I have already uploaded a Debian package of > python-cheetah 2.4.2.1 which includes this patch. So don't worry about > the update ;), especially because I seem to be the only one to report > such issue. #ifndef PyUnicode_FromFormat #define PyUnicode_FromFormat(a, b) PyString_FromFormat(a, b) #end def I define similar macros for supporting Python 2.4/2.5 with another one of my projects: http://github.com/rtyler/py-yajl/blob/master/py_yajl.h#L64 > > >> BTW, my question may be silly but I'm wondering why `newExcValue' > >> reference returned by PyUnicode_FromFormat() > >> (wrapInternalNotFoundException() function) is never DECREF > >> whereas it is in setNotFoundException() function for > >> `exceptionStr'. Just curious ;)... > > Any thoughts about that? ;) Probably a bug, the _namemapper.c code needs some love. Cheers, -R. Tyler Ballance -------------------------------------- Jabber: rtyler@... GitHub: http://github.com/rtyler Twitter: http://twitter.com/agentdero Blog: http://unethicalblogger.com ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
Re: [PATCH] C extension fails to build on Python 2.5 because of PyUnicode_FromFormatHi,
>> Does the patch look alright? I have already uploaded a Debian >> package of python-cheetah 2.4.2.1 which includes this patch. So >> don't worry about the update ;), especially because I seem to be >> the only one to report such issue. > Regarding the patch, I think I might rather add somtehing like the > following: > #ifndef PyUnicode_FromFormat #define PyUnicode_FromFormat(a, > b) PyString_FromFormat(a, b) #end def No patch seems to have been applied about that, any update? Thanks. Cheers, -- Arnaud Fontaine ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
| Free embeddable forum powered by Nabble | Forum Help |