473,748 Members | 9,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IMPORTANT 2.5 API changes for C Extension Modules and Embedders

If you don't write or otherwise maintain Python Extension Modules
written in C (or C++) or embed Python in your application,
you can stop reading.

Python 2.5 alpha 1 was released April 5, 2006. The second alpha
should be released in a few weeks. There are several changes
which can cause C extension modules or embedded applications
to crash the interpreter if not fixed. Periodically, I will send out
these reminders with updated information until 2.5 is released.

* support for 64-bit sequences (eg, > 2GB strings)
* memory allocation modifications

64-bit changes
--------------
There are important changes that are in 2.5 to support 64-bit systems.
The 64-bit 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-0...ion-guidelines

The effbot wrote a program to check your code and find potential
problems with the 64-bit APIs.
http://svn.effbot.python-hosting.com.../ssizecheck.py

Memory Allocation Modifications
-------------------------------
In previous versions of Python, it was possible to use different
families of APIs (PyMem_* vs. PyObject_*) to allocate and free
the same block of memory. APIs in these families include:

PyMem_*: PyMem_Malloc, PyMem_Realloc, PyMem_Free,
PyObject_*: PyObject_Malloc , PyObject_Reallo c, PyObject_Free

There are a few other APIs with similar names and also the macro variants.

In 2.5, if allocate a block of memory with one family, you must reallocate
or free with the same family. That means:

If you allocate with PyMem_Malloc (or MALLOC), you must reallocate
with PyMem_Realloc (or REALLOC) and free with PyMem_Free (or FREE).
If you allocate with PyObject_Malloc (or MALLOC), you must reallocate
with PyObject_Reallo c (or REALLOC) and free with PyObject_Free (or FREE).

Using inconsistent APIs can cause double frees or otherwise crash
the interpreter. It is fine to mix and match functions or macros
within the same family.

Please test and upgrade your extension modules!

Cheers,
n
Apr 12 '06 #1
0 849

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3440
by: ronwer | last post by:
Hello, The title doesn't completely cover the question I have, but it's a bit more complicated problem we have. We are using a database, based on Acces, but developed by a third party developer who sells it under his own name. So, functionally it's a very specific database for a specific purpose. Now we want to make certain changes in this database, but for reasons of
3
1884
by: Simon Burton | last post by:
Hi, I'm having some trouble linking one extension module to another because the linker expects a "lib" prefix and my python modules cannot have this prefix. I found two ways of doing it on a linux box (either symlink or create a dummy .so that links to extension module) but I can get neither of them work on OSX (let alone windows).
3
1010
by: nnorwitz | last post by:
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...
1
4290
by: zpinhead | last post by:
I am unable to get my downloaded extension from pecl to link up with php properly. seems like the php.so I could not use pear install http. pear claimed the extension was already installed. that is certainly not true. I downloaded the http extension from pecl. cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/http
1
1632
by: Mark Asbach | last post by:
Hi pythonians, I'm one of the maintainers of an open source image processing toolkit (OpenCV) and responsible for parts of the autotools setup. The package mainly consists of four shared libraries but is accompanied by a python package containing some pure python code and of course extension modules for the four libraries. Now during the last month we were preparing a major release which means testing, fixing, testing, fixing, ... in...
1
2083
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules written using other languages. Extensions of Python could be done via special interpreter extensions. From Python sources, the special modules would look like other modules, with the Python API (the key feature from
0
3841
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. · What are user controls and custom controls? Custom controls: A control authored by a user or a third-party software vendor that...
1
2024
by: Stefan Braumeister | last post by:
Hi NG, I got some difficult problem that drives me nuts. I wrote a relatively simple extension that reads binary files and extracts some data. If I call the script, that uses my extension via webbrowser, apache sometimes segfaults with: *** glibc detected *** free(): invalid next size (normal): 0x0000555555a7c240 ***
15
3223
by: kyosohma | last post by:
Hi, I am trying to get a small group of volunteers together to create Windows binaries for any Python extension developer that needs them, much like the package/extension builders who volunteer their time to create Linux RPMs. The main thing I need are people willing to test the binaries to make sure the extension is stable. This would require installing the binary and probably downloading the source too to get the developer's test
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.