[Python-Dev] C API doc fix

Robey Pointer robey at lag.net
Mon Oct 10 19:18:13 CEST 2005


On 29 Sep 2005, at 12:06, Steven Bethard wrote:

> On 9/29/05, Robey Pointer <robey at lag.net> wrote:
>
>> Yesterday I ran into a bug in the C API docs.  The top of this page:
>>
>>      http://docs.python.org/api/unicodeObjects.html
>>
>> says:
>>
>> Py_UNICODE
>>      This type represents a 16-bit unsigned storage type which is
>> used by Python internally as basis for holding Unicode ordinals. On
>> platforms where wchar_t is available and also has 16-bits, Py_UNICODE
>> is a typedef alias for wchar_t to enhance native platform
>> compatibility. On all other platforms, Py_UNICODE is a typedef alias
>> for unsigned short.
>>
>
> I believe this is the same issue that was brought up in May[1].  My
> impression was that people could not agree on a documentation patch.

Would it help if I tried my hand at it?  My impression so far is that  
extension coders should probably try not to worry about the size or  
content of Py_UNICODE.  (The thread seems to have wandered off into  
nowhere again...)


Py_UNICODE
This type represents an unsigned storage type at least 16-bits long  
(but sometimes more) which is used by Python internally as basis for  
holding Unicode ordinals. On platforms where wchar_t is available and  
also has 16-bits, Py_UNICODE is a typedef alias for wchar_t to  
enhance native platform compatibility.  In general, you should use  
PyUnicode_FromEncodedObject and PyUnicode_AsEncodedString to convert  
strings to/from unicode objects, and consider Py_UNICODE to be an  
implementation detail.


robey



More information about the Python-Dev mailing list