This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author stutzbach
Recipients lemburg, loewis, pitrou, stutzbach
Date 2010-05-21.13:55:02
SpamBayes Score 3.7829777e-05
Marked as misclassified No
Message-id <1274450105.57.0.555651103047.issue8781@psf.upfronthosting.co.za>
In-reply-to
Content
Usually you wouldn't want to cast a char directly to a Py_UNICODE, because you need to take into account the encoding of the char and map it to the appropriate Unicode character.  The exception is when you're certain the char is 7-bit ASCII, which is a subset of Unicode; that's safe since 7-bit ASCII never uses the sign bit.

However, again, I'm not an expert on the internals of Python's Unicode implementation and it's possible that I'm missing something.  ;) You also raise a good point about third-party code.

Your other suggestion is quite workable.  ./configure could define HAVE_USABLE_WCHAR_T (which is used to enable the optimizations) when sizeof(wchar_t) == sizeof(Py_UNICODE), yet still define Py_UNICODE as unsigned.  Using Google Code I could not find any instances of HAVE_USABLE_WCHAR_T being used outside of CPython itself.

Another option would be to test Py_UNICODE_SIZE == SIZEOF_WCHAR_T to enable the optimizations, instead of defined(HAVE_USABLE_WCHAR_T).  The plus side is that we wouldn't be changing the semantics of anything.
History
Date User Action Args
2010-05-21 13:55:05stutzbachsetrecipients: + stutzbach, lemburg, loewis, pitrou
2010-05-21 13:55:05stutzbachsetmessageid: <1274450105.57.0.555651103047.issue8781@psf.upfronthosting.co.za>
2010-05-21 13:55:03stutzbachlinkissue8781 messages
2010-05-21 13:55:02stutzbachcreate