Are we still planning to provide a mechanism to declare APIs, etc as deprecated? I have this code added to pyport.h which works for gcc: /* Py_DEPRECATED(version) * Declare a macro or function deprecated. * Usage: * extern int old_var Py_DEPRECATED(2.3); * typedef int T1 Py_DEPRECATED(2.4); * extern int x() Py_DEPRECATED(2.5); */ #if defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) #else #define Py_DEPRECATED(VERSION_UNUSED) #endif The version number is not necessary. It is only for documentation. I don't know how to support other compilers. We could add Py_USE_DEPRECATED and/or Py_HIDE_DEPRECATED for providing/hiding access to deprecated features. #ifdef Py_USE_DEPRECATED #define Py_SOME_DEPRECATED_MACRO #endif or #ifndef Py_HIDE_DEPRECATED #define Py_SOME_DEPRECATED_MACRO #endif Unfortunately, the Py_DEPRECATED macro doesn't work with macros, so we would have to use Py_USE_DEPRECATED/Py_HIDE_DEPRECATED around deprecated macros. Neal
Are we still planning to provide a mechanism to declare APIs, etc as deprecated?
I think this is a neat idea.
I have this code added to pyport.h which works for gcc:
/* Py_DEPRECATED(version) * Declare a macro or function deprecated. * Usage: * extern int old_var Py_DEPRECATED(2.3); * typedef int T1 Py_DEPRECATED(2.4); * extern int x() Py_DEPRECATED(2.5); */ #if defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) #else #define Py_DEPRECATED(VERSION_UNUSED) #endif
The version number is not necessary. It is only for documentation. I don't know how to support other compilers.
What does this do under GCC? I suppose it issues a warning when you use the deprecated API?
We could add Py_USE_DEPRECATED and/or Py_HIDE_DEPRECATED for providing/hiding access to deprecated features.
#ifdef Py_USE_DEPRECATED #define Py_SOME_DEPRECATED_MACRO #endif
or
#ifndef Py_HIDE_DEPRECATED #define Py_SOME_DEPRECATED_MACRO #endif
Unfortunately, the Py_DEPRECATED macro doesn't work with macros, so we would have to use Py_USE_DEPRECATED/Py_HIDE_DEPRECATED around deprecated macros.
That's OK. Just the fact that when reading the .h files one sees the DEPRECATED keyword should be a big hint... --Guido van Rossum (home page: http://www.python.org/~guido/)
On Wed, Dec 18, 2002 at 10:54:34PM -0500, Guido van Rossum wrote:
What does this do under GCC? I suppose it issues a warning when you use the deprecated API?
I modified abstract.h: - PyAPI_FUNC(int) PyNumber_Check(PyObject *o); + PyAPI_FUNC(int) PyNumber_Check(PyObject *o) Py_DEPRECATED(2.3); I used PyNumber_Check in selectmodule.c and got: Modules/selectmodule.c: In function `select_select': Modules/selectmodule.c:211: warning: `PyNumber_Check' is deprecated (declared at Include/abstract.h:534) Neal
What does this do under GCC? I suppose it issues a warning when you use the deprecated API?
I modified abstract.h:
- PyAPI_FUNC(int) PyNumber_Check(PyObject *o); + PyAPI_FUNC(int) PyNumber_Check(PyObject *o) Py_DEPRECATED(2.3);
I used PyNumber_Check in selectmodule.c and got:
Modules/selectmodule.c: In function `select_select': Modules/selectmodule.c:211: warning: `PyNumber_Check' is deprecated (declared at Include/abstract.h:534)
Neat! +1. Now it's time to make a list of APIs we want to declare deprecated. (Some have probably been deprecated for quite a while...) --Guido van Rossum (home page: http://www.python.org/~guido/)
On Thu, Dec 19, 2002 at 09:59:10AM -0500, Guido van Rossum wrote:
Now it's time to make a list of APIs we want to declare deprecated. (Some have probably been deprecated for quite a while...)
There are only 847. :-) I don't think this really helps... But for usage counts (by grep): http://www.metaslash.com/py/api-counts.txt If nothing else, it's a quick list of names to look over. Neal
participants (3)
-
Guido van Rossum
-
Neal Norwitz
-
Neil Schemenauer