Message115437
| Author |
stutzbach |
| Recipients |
Arfrever, gvanrossum, lemburg, loewis, r.david.murray, scoder, stutzbach, vstinner, zooko |
| Date |
2010年09月03日.11:05:16 |
| SpamBayes Score |
1.3364865e-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? |
|