[Python-Dev] Re: [Python-checkins]python/dist/src/Objects unicodeobject.c, 2.197, 2.198

M.-A. Lemburg mal at lemburg.com
Sun Sep 21 07:30:27 EDT 2003


Tim Peters wrote:
> [M.-A. Lemburg]
> 
>>>Since wchar_t is the only case where a signed type can pop
>>>up, why not extend the autoconf test to check for signedness
>>>and then reject signed wchar_t value as not-usable (ie.
>>>undefine HAVE_USABLE_WCHAR_T).
> 
> [martin at v.loewis.de]
> 
>>Because that would exclude a number of relevant systems where wchar_t
>>would be usable.
> 
> So what if MAL ammened his suggestion to
> 
>     reject signed 2-byte wchar_t value as not-usable
>                  +++++++
> ?

That would not solve the problem.

Note that we have proper conversion routines that allow
converting between wchar_t and Py_UNICODE. These routines must
be used for conversions anyway (even if Py_UNICODE and wchar_t
happen to be the same type), so from a programmer perspective
changing Py_UNICODE to be unsigned won't be noticed and we
don't lose anything much.

Again, I don't see the point in using a signed type for data
that doesn't have any concept of signed values. It's just
bad design and we shouldn't try to go down the same route
if we don't have to.

The Unicode implementation has always defined Py_UNICODE to
be an unsigned type; see the Unicode PEP 100:

"""
Internal Format

     The internal format for Unicode objects should use a Python
     specific fixed format <PythonUnicode> implemented as 'unsigned
     short' (or another unsigned numeric type having 16 bits).  Byte
     order is platform dependent.

...

     The configure script should provide aid in deciding whether Python
     can use the native wchar_t type or not (it has to be a 16-bit
     unsigned type).
"""

Python can also deal with UCS4 now, but the concept remains the
same.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Sep 21 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::




More information about the Python-Dev mailing list