Skip to content

isalpha bug #48564

Closed
Closed

Description

@ZooKeeper
mannequin
BPO 4314
Nosy @malemburg, @vstinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-11-13.14:49:53.915>
created_at = <Date 2008-11-13.14:39:37.547>
labels = ['type-bug', 'expert-unicode']
title = 'isalpha bug'
updated_at = <Date 2008-11-13.15:57:45.777>
user = 'https://bugs.python.org/ZooKeeper'

bugs.python.org fields:

activity = <Date 2008-11-13.15:57:45.777>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2008-11-13.14:49:53.915>
closer = 'lemburg'
components = ['Unicode']
creation = <Date 2008-11-13.14:39:37.547>
creator = 'ZooKeeper'
dependencies = []
files = []
hgrepos = []
issue_num = 4314
keywords = []
message_count = 7.0
messages = ['75820', '75821', '75822', '75823', '75824', '75826', '75827']
nosy_count = 3.0
nosy_names = ['lemburg', 'vstinner', 'ZooKeeper']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue4314'
versions = ['Python 2.5']

Activity

  1. ZooKeeper commented on Nov 13, 2008

    ZooKeepermannequin
    MannequinAuthor

    This may be a little tricky to recreate but here it is:

    q = u'абвгде'
    q.isalpha()
    True
    
    foo = u'ч'
    foo.isalpha()
    False

    So the Russian character u'ч' and u'ё' as well as a bunch of others is
    not recognized by isalpha as a alphabetic character, which it is a
    matter of fact.
    This applies to both capital and regular versions of the letters.

    http://en.wikipedia.org/wiki/%D0%81
    http://en.wikipedia.org/wiki/Che_(Cyrillic)

    Using: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
    (Intel)] on win32

  2. added
    extension-modules
    type-bug
    on Nov 13, 2008
  3. malemburg commented on Nov 13, 2008

    @malemburg
    Member

    Are you sure that you've used the right source code encoding for writing
    these characters ?

    Note that the Unicode .isalpha() method relies entirely on what the
    Unicode database provides as code point information. If a character is
    marked as not being alphanumeric (ie. is not in one of the categories
    'Ll', 'Lu', 'Lt', 'Lo' or 'Lm'), it will return False.

  4. removed
    extension-modules
    on Nov 13, 2008
  5. malemburg commented on Nov 13, 2008

    @malemburg
    Member

    FWIW: I get the following in Python 2.5:

    >>> print u'\u0401'
    Ё
    >>> print u'\u0451'
    ё
    >>> print u'\u0401'.isalpha()
    True
    >>> print u'\u0451'.isalpha()
    True
  6. malemburg commented on Nov 13, 2008

    @malemburg
    Member

    ... and for the other character:

    >>> print u'\u0427'
    Ч
    >>> print u'\u0447'
    ч
    >>> print u'\u0427'.isalpha()
    True
    >>> print u'\u0447'.isalpha()
    True

    Looks fine.

  7. vstinner commented on Nov 13, 2008

    @vstinner
    Member

    Results on Linux:

    With Python 2.7 trunk:
    >>> print(', '.join('%s:%s' % (c, c.isalpha()) for c in u'абвгдеч'))
    а:True, б:True, в:True, г:True, д:True, е:True, ч:True
    
    With Python 2.5.1:
    >>> print(', '.join('%s:%s' % (c, c.isalpha()) for c in u'абвгдеч'))
    а:True, б:True, в:True, г:True, д:True, е:True, ч:True
    
    With Python 3.0 trunk:
    >>> print(', '.join('%s:%s' % (c, c.isalpha()) for c in 'абвгдеч'))
    а:True, б:True, в:True, г:True, д:True, е:True, ч:True

    Are you sure that you really typed the character "ч"? Can you retry
    using unichr(0x447).isalpha()?

    Test with Python3:
    >>> print(' - '.join((r"\u%04x" % x) for x in range(0x400, 0x4ff+1) if 
    not chr(x).isalpha()))
    \u0482 - \u0483 - \u0484 - \u0485 - \u0486 - \u0487 - \u0488 - \u0489

    Which means that Python thinks that all unicode character in range
    U+0400..U+04ff are letters except the range U+0482..U+0489 (thousands
    sign ҂ to million sign ҉).

  8. ZooKeeper commented on Nov 13, 2008

    ZooKeepermannequin
    MannequinAuthor

    I'll investigate it in further shortly, but for now replicating the test.
    print u'\u0451'
    ¸
    print u'\u0427'
    ×

    Something must be going on here. Running Win XP.

  9. vstinner commented on Nov 13, 2008

    @vstinner
    Member
    $ python
    Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
    >>> print u'\u0451'
    ё
    >>> print u'\u0427'
    Ч

    @ZooKeeper: Try Python 2.6, I guess that your bug is already fixed.

  10. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-unicodetype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions