[Python-Dev] Name space pollution (fwd) (original) (raw)

Guido van Rossum guido@python.org
Wed, 22 Jan 2003 22:20:18 -0500


I'm trying to get Python to coexist with the State Threads library (http://state-threads.sourceforge.net/), but I'm having problems due to the fact that Python defines the word "destructor" as a typedef. Specifically, after including Python.h, the following line in the State Threads header file st.h does not compile:

extern int stkeycreate(int *keyp, void (*destructor)(void *)); It seems to me that Python should not be polluting the namespace this way - shouldn't the Python typedef be something like PyDestructor instead of just "destructor"? Python also pollutes a number of other common symbols in a similar way, for example, "cmpfunc", "hashfunc", and "initproc". Is there any chance this will be fixed?

If you care about this, submit a patch.

But it may be a lot easier to do some #define magic, e.g.

#define destructor PyDestructor #include "Python.h" #undef destructor #include "st.h"

--Guido van Rossum (home page: http://www.python.org/~guido/)