Author stutzbach
Recipients Arfrever, gvanrossum, lemburg, loewis, r.david.murray, scoder, stutzbach, vstinner, zooko
Date 2010-09-03.11:05:16
SpamBayes Score 1.33649e-12
Marked as misclassified No
Message-id <1283511925.66.0.0891042754262.issue8654@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2010-09-03 11:05:25stutzbachsetrecipients: + stutzbach, lemburg, gvanrossum, loewis, zooko, scoder, vstinner, Arfrever, r.david.murray
2010-09-03 11:05:25stutzbachsetmessageid: <1283511925.66.0.0891042754262.issue8654@psf.upfronthosting.co.za>
2010-09-03 11:05:24stutzbachlinkissue8654 messages
2010-09-03 11:05:23stutzbachcreate