module random from python2.3 to python2.2
sample() is missing in python2.2
In python2.2, random is just a monolithic python program. Whereas in python2.3, there's an additional _randommodule.c, c module and it's very hard to compile in python2.2. Even after I added following:
#ifndef PyDoc_STR #define PyDoc_VAR(name) static char name[] #define PyDoc_STR(str) (str) #define PyDoc_STRVAR(name, str) PyDoc_VAR(name) = PyDoc_STR(str) #endif #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ #define PyMODINIT_FUNC void #endif
it still got "segmentation fault" when importing.
On the other hand, sample() of python2.3 doesn't rely on the c module. So i just copied the whole sample function plus inserted "sample = _inst.sample" into the end of random.py. Now everything is fine.