[Python-Dev] PyUnicode_GetMax() and PyUnicode_FromOrdinal() Was: Breaking undocumented API

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Nov 16 21:31:13 CET 2010

On Tue, Nov 16, 2010 at 3:06 PM, M.-A. Lemburg <mal at egenix.com> wrote:
>>>>> len(chr(0x10FFFF))
>> 2
>> (on a USC2 build.)
> Yes, it's a documentation bug. I guess someone forgot to update
> the comment in unicodeobject.h after the change to have chr()/unichr()
> return a 2-char string instead of a 1-char string for non-BMP
> code points.

Same problem in reST doc for chr(i):


Return the string of one character whose Unicode codepoint is the
integer i. For example, chr(97) returns the string 'a'. This is the
inverse of ord(). The valid range for the argument depends how Python
was configured – it may be either UCS2 [0..0xFFFF] or UCS4
[0..0x10FFFF]. ValueError will be raised if i is outside that range.
""" http://docs.python.org/dev/py3k/library/functions.html?chr

And in ord(c):


Given a string of length one, return an integer representing the
Unicode code point of the character. For example, ord('a') returns the
integer 97 and ord('\u2020') returns 8224. This is the inverse of

If the argument length is not one, a TypeError will be raised. (If
Python was built with UCS2 Unicode, then the character’s code point
must be in the range [0..65535] inclusive; otherwise the string length
is two!)
""" http://docs.python.org/dev/py3k/library/functions.html#ord

More information about the Python-Dev mailing list