Daniel Stutzbach <dan...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue8654>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to