IMPORTANT 2.5 API changes for C Extension Modules

57 views
Skip to first unread message

nnor...@gmail.com

unread,
Apr 5, 2006, 2:44:16 AM4/5/06
to
If you don't write or otherwise maintain Python Extension Modules
written in C (or C++), you can stop reading.

Python 2.5 alpha 1 is in the process of being released later today.
There are important changes that are in 2.5 to support 64-bit systems.
These changes can cause Python to crash if your module is not upgraded
to support the changes. Python was changed internally to use 64-bit
values on 64-bit machines for indices. If you've got a machine with
more than 16 GB of RAM, it would be great if you can test Python with
large (> 2GB) strings and other sequences.

For more details about the Python 2.5 schedule:
http://www.python.org/dev/peps/pep-0356/
For more details about the 64-bit change:
http://www.python.org/dev/peps/pep-0353/
How to fix your module:
http://www.python.org/dev/peps/pep-0353/#conversion-guidelines

The effbot wrote a program to check your code and find potential
problems.
http://svn.effbot.python-hosting.com/stuff/sandbox/python/ssizecheck.py

Please test and upgrade your extension modules!

Cheers,
n

David Rushby

unread,
Apr 5, 2006, 9:27:04 PM4/5/06
to
Thank you for taking the time to pull the relevant links together and
make this post, Neal.

konrad...@laposte.net

unread,
Apr 6, 2006, 6:46:56 AM4/6/06
to nnor...@gmail.com, pytho...@python.org
On 05.04.2006, at 08:44, nnor...@gmail.com wrote:

> Python 2.5 alpha 1 is in the process of being released later today.
> There are important changes that are in 2.5 to support 64-bit systems.
> These changes can cause Python to crash if your module is not upgraded
> to support the changes. Python was changed internally to use 64-bit
> values on 64-bit machines for indices. If you've got a machine with
> more than 16 GB of RAM, it would be great if you can test Python with
> large (> 2GB) strings and other sequences.
>
> For more details about the Python 2.5 schedule:
> http://www.python.org/dev/peps/pep-0356/
> For more details about the 64-bit change:
> http://www.python.org/dev/peps/pep-0353/
> How to fix your module:
> http://www.python.org/dev/peps/pep-0353/#conversion-guidelines

Thanks for the information!

One question: Is there a safe way to keep extension modules backward-
compatible with older Python versions? I am thinking of something like

#ifndef PY_SSIZE_T_DEFINED
typedef Py_ssize_t int;
#endif

assuming that Python 2.5 defines PY_SSIZE_T_DEFINED.

Konrad.
--
------------------------------------------------------------------------
-------
Konrad Hinsen
Laboratoire Leon Brillouin (CEA-CNRS), CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: konrad...@cea.fr
------------------------------------------------------------------------
-------


Fredrik Lundh

unread,
Apr 6, 2006, 6:49:42 AM4/6/06
to pytho...@python.org
konrad...@laposte.net wrote:

> One question: Is there a safe way to keep extension modules backward-
> compatible with older Python versions?

absolutely.

> I am thinking of something like
>
> #ifndef PY_SSIZE_T_DEFINED
> typedef Py_ssize_t int;
> #endif
>
> assuming that Python 2.5 defines PY_SSIZE_T_DEFINED.

the "official" way to do this is described in the conversion guidelines:

http://www.python.org/dev/peps/pep-0353/#conversion-guidelines

</F>

Reply all
Reply to author
Forward
0 new messages