This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author moog
Recipients moog
Date 2011-03-30.16:21:44
SpamBayes Score 2.33085e-10
Marked as misclassified No
Message-id <1301502105.52.0.181374026279.issue11722@psf.upfronthosting.co.za>
In-reply-to
Content
Bulding a simple extension (the spam example) fails with mingw64.

in modsupport.h, the following is used to detect 64bit, it does not work with mingw64.

#if SIZEOF_SIZE_T != SIZEOF_INT
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4
   modules cannot get loaded into a 2.5 interpreter */
#define Py_InitModule4 Py_InitModule4_64
#endif

This code never compiles, you can test this by placing similar code and filling it with rubbish.

This means it thinks the extension is being built on a 32bit compiler and creates the wrong call for Py_InitModule.

Workaround:
Explicitly calling Py_InitModule4_64() in extension and declaring Py_InitModule4_64(...) in code. Note this does not complain about re-declaration and builds OK because declaration is wrong.
e.g.
//m=Py_InitModule("spam", SpamMethods);
m = Py_InitModule4_64("spam", SpamMethods,(char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);


Or, a better more portable permanent fix, define WIN64 in code and
modify modsupport.h:
#if SIZEOF_SIZE_T != SIZEOF_INT || defined(WIN64)
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4
   modules cannot get loaded into a 2.5 interpreter */
#define Py_InitModule4 Py_InitModule4_64
#endif

I am sure there are other, more standard ways.
History
Date User Action Args
2011-03-30 16:21:45moogsetrecipients: + moog
2011-03-30 16:21:45moogsetmessageid: <1301502105.52.0.181374026279.issue11722@psf.upfronthosting.co.za>
2011-03-30 16:21:44mooglinkissue11722 messages
2011-03-30 16:21:44moogcreate