[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

Daniel Stutzbach report at bugs.python.org
Fri Sep 3 13:05:25 CEST 2010


Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:

I just noticed that the previous "new" patch I uploaded was actually my original patch.  Oops.  Anyway...

In a discussion on the capi list, a few people objected to compiling in Unicode-agnostic mode by default (e.g., it would be annoying for Cython).  Attached is a new patch that compiles in Unicode-agnostic mode only when Py_UNICODE_AGNOSTIC is defined (and brings the patch up to date with other changes to the py3k branch).

It includes automated tests, and I have tested UCS2 Linux, UCS4 Linux, and Windows builds.

After the patch, trying to import a module with a mismatched Unicode setting looks like this:

>>> import _testunicodemismatched
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: module's Unicode representation does not match the interpreter's

Here's a birds-eye view of the patch:

moduleobject.h: Add a flags field to PyModuleDef_Base
moduleobject.c: Detect import with mismatched Unicode setting
pyunicode.h: New file; non-agnostic code from unicodeobject.h moved here
unicodeobject.h: Deleted ~150 lines of #defines (yay!)
Everything else: tests

I'm pretty happy with the patch.  In the earlier discussion here, there was generally positive feedback for the overall idea.  Someone want to do a patch review?

----------
keywords: +needs review
stage: needs patch -> patch review
Added file: http://bugs.python.org/file18723/unicode-2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8654>
_______________________________________


More information about the Python-bugs-list mailing list