[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 10:15:41 CEST 2006


neal.norwitz schrieb:
> Author: neal.norwitz
> Date: Sun Jul 30 08:55:48 2006
> New Revision: 50969
> 
> Modified:
>    python/trunk/Include/pyerrors.h
>    python/trunk/Misc/NEWS
>    python/trunk/Modules/_struct.c
>    python/trunk/Python/errors.c
> Log:
> Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().
> This provides the proper warning for struct.pack().
> PyErr_Warn() is now deprecated in favor of PyErr_WarnEx().
> As mentioned by Tim Peters on python-dev.
> 
> 
> Modified: python/trunk/Include/pyerrors.h
> ==============================================================================
> --- python/trunk/Include/pyerrors.h	(original)
> +++ python/trunk/Include/pyerrors.h	Sun Jul 30 08:55:48 2006
> @@ -225,10 +225,14 @@
>  PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
>  
>  /* Issue a warning or exception */
> -PyAPI_FUNC(int) PyErr_Warn(PyObject *, char *);
> +PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg,
> +			     Py_ssize_t stack_level);
>  PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
>  				   const char *, int, 
>  				   const char *, PyObject *);
> +/* PyErr_Warn is only for backwards compatability and will be removed.
> +   Use PyErr_WarnEx instead. */
> +#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
>  

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.

Thomas



More information about the Python-checkins mailing list