[issue10521] str methods don't accept non-BMP fillchar on a narrow Unicode build

Alexander Belopolsky report at bugs.python.org
Thu Nov 25 06:01:40 CET 2010


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Wed, Nov 24, 2010 at 3:37 PM, Marc-Andre Lemburg
<report at bugs.python.org> wrote:
..
> I don't think we should change that for the formatting methods.

That's a reasonable position.  What about

>>> unicodedata.category('\N{OLD ITALIC LETTER A}')
'Lo'
>>> '\N{OLD ITALIC LETTER A}'.isalpha()
False

the str.isalpha() method is underspecified in the reference manual,
but a comment in unicodectype.c describes Py_UNICODE_ISALPHA as
follows:

/* Returns 1 for Unicode characters having the category 'Ll', 'Lu',
'Lt',
  'Lo' or 'Lm',  0 otherwise. */

I don't have a wide build handy, but I am fairly sure  '\N{OLD ITALIC
LETTER A}'.isalpha() would produce True there.  The result above is
simply consequence of surrogates considered to be non-letters:

>>> [c.isalpha() for c in '\N{OLD ITALIC LETTER A}']
[False, False]

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10521>
_______________________________________


More information about the Python-bugs-list mailing list