Author stutzbach
Recipients stutzbach
Date 2010-05-07.19:24:08
SpamBayes Score 4.36494e-06
Marked as misclassified No
Message-id <1273260250.9.0.405940490001.issue8654@psf.upfronthosting.co.za>
In-reply-to
Content
Forcing the compile-time and link-time encodings to match is tricky.  The goal is:

- Allow Unicode-agnostic modules to link, regardless of unicode settings
- Cause a link failure if the unicode settings are mismatched for a module that pokes into PyUnicodeObject

All of the solutions I've come up with have trade-offs.  Here is one approach:

Expose PyUnicodeObject if and only if the extension #defines a special flag (PY_EXPOSE_UNICODE_OBJECT?) before including Python.h.

If an extension does NOT define the flag, then PyUnicodeObject will not be defined nor the accessor macros for accessing its fields.  All of the opaque and non-opaque functions are still defined; the module just can't poke directly into PyUnicodeObject.  Linking will succeed as long as the module avoids non-opaque functions.

If the flag IS defined, then PyUnicodeObject will be defined along with the accessor macros.  The unicodeobject.h header will also arrange to require an appropriate symbol so that linking will succeed only if the module is compiled with the same Unicode settings as Python.

The upside of this approach is that it works: Unicode-agnostic modules will link and all others will not.

The drawback is a few extension modules will need to have a #define before including Python.h.  Only modules that poke into PyUnicodeObject will be impacted.  No change will be required for modules that depend on the Unicode setting yet stick to functions (opaque or not).

Thoughts?
History
Date User Action Args
2010-05-07 19:24:10stutzbachsetrecipients: + stutzbach
2010-05-07 19:24:10stutzbachsetmessageid: <1273260250.9.0.405940490001.issue8654@psf.upfronthosting.co.za>
2010-05-07 19:24:09stutzbachlinkissue8654 messages
2010-05-07 19:24:08stutzbachcreate