[Python-checkins] r50969 - in python/trunk: Include/pyerrors.h Misc/NEWS Modules/_struct.c Python/errors.c

Thomas Heller theller at python.net
Fri Aug 4 19:46:52 CEST 2006


Neal Norwitz schrieb:
> On 8/4/06, M.-A. Lemburg <mal at egenix.com> wrote:
>> >
>> > This change removed (on Windows) the PyErr_Warn *exported* function from
>> > the python25.dll.  As a result, extensions compiled with earlier beta versions
>> > of python 2.5 cannot be loaded any more; for example the win32com extensions
>> > from Mark Hammond - but of course any other extensions that use this function.
>> >
>> > Btw: Shouldn't the PYTHON_API_VERSION (or how it's called) have also been changed?
>> >
>> > I'm unsure what to do:
>> > - Implement PyErr_Warn as a function again (this was also done with other functions,
>> >   see also #1465834).  Would this require another beta ;-)?
>> > - Leave it as it is, and require that extensions needs to be rebuilt with 2.5b3
>> >   (plus change the PYTHON_API_VERSION, ...)
>> >
>> > Anyway, it seems to me that *some* policy regarding changes to exported functions
>> > should be established.
>>
>> In the past we've always kept a stub function around that
>> was exported when converting a function to a macro.
>>
>> I guess this ought to happen in this case as well.
> 
> That was my intent.  I thought I left it in the C file so it would be
> in a library, but any newly compiled code would use the new API.

Ah, I didn't look into Python/errors.h.  The function must be marked PyAPI_FUNC
to be exported from the dll.

> Thomas if you can work up a patch, that would be great.  I will try to
> take a look at it later.

Index: errors.c
===================================================================
--- errors.c	(Revision 51087)
+++ errors.c	(Arbeitskopie)
@@ -664,7 +664,7 @@
 
 #undef PyErr_Warn
 
-int
+PyAPI_FUNC(int)
 PyErr_Warn(PyObject *category, char *message)
 {
 	return PyErr_WarnEx(category, message, 1);

Just for fun: with ctypes, testing for this is trivial.  First, Python 2.5b3:

Python 2.5b3 (r25b3:51041, Aug  3 2006, 09:35:06) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> pythonapi.PyErr_Warn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\svn\theller\ctypes\ctypes\__init__.py", line 328, in __getattr__
    func = self.__getitem__(name)
  File "c:\svn\theller\ctypes\ctypes\__init__.py", line 333, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'PyErr_Warn' not found
>>> ^Z

Then, Python SVN trunk with this patch:

Python 2.5b3 (trunk:51087M, Aug  4 2006, 19:43:25) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> pythonapi.PyErr_Warn
<_FuncPtr object at 0x009E6E40>
>>> ^Z

Thomas


More information about the Python-checkins mailing list