[Pyrex] Updated Python 2.5 patch
Stefan Behnel
behnel_ml at gkec.informatik.tu-darmstadt.de
Sat May 6 10:38:00 CEST 2006
Hello again,
Stefan Behnel wrote:
> here is an updated (complete) patch for running Pyrex on Python 2.5. Compared
> to the last patch, it fixes the default slice end index, which is now
> PY_SSIZE_T_MAX instead of a plain 32bit integer 0x7fffffff.
>
> It still compiles nicely on Python 2.4. I couldn't test earlier versions, but
> problems are unlikely as there are practically no changes in API usage in this
> environment. Tests are always welcome, though.
... and here's another one. I removed the support for "Py_ssize_t" as standard
C type from the parser, the difference to the previous patch is the following:
----------------------------
Index: Pyrex/Compiler/Parsing.py
===================================================================
--- Pyrex/Compiler/Parsing.py (Revision 136)
+++ Pyrex/Compiler/Parsing.py (Arbeitskopie)
@@ -1257,7 +1257,7 @@
# "void", "signed", "unsigned"
#)
-basic_c_type_names = ("void", "char", "int", "float", "double", "Py_ssize_t")
+basic_c_type_names = ("void", "char", "int", "float", "double")
sign_and_longness_words = ("short", "long", "signed", "unsigned")
----------------------------
This means that Py_ssize_t is no longer provided to the "outside world". You
must import it from "Python.h" (just as PyObject and the like):
cdef extern from "Python.h":
ctypedef int Py_ssize_t
I think that's a better solution as it keeps the Pyrex language unchanged.
Also, if you want new code to be compilable with old versions of Pyrex, you
need this somewhere in an imported header file:
------------------------------------
/* Py_ssize_t support was added in Python 2.5 and Pyrex 0.9.X */
#if PY_VERSION_HEX < 0x02050000
#ifndef PY_SSIZE_T_MAX
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
#endif
#endif
------------------------------------
The "#ifndef" is needed as the patched Pyrex already defines this section.
I hope this will be integrated rather soon so that people can start preparing
their Pyrex code for Python 2.5.
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Py2.5.patch
Type: text/x-patch
Size: 14381 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20060506/5d4f088c/Py2.5.bin
More information about the Pyrex
mailing list