Skip to content

Bad regexp escape in babel.plural #472

Closed

Description

@jwilk

babel/plural.py contains the following line:

    ('ellipsis', re.compile(r'\.{2,3}|\u2026', re.UNICODE))  # U+2026: ELLIPSIS

But \uXXXX escape sequences in regexps were added only in Python 3.3.
In earlier versions, \u stands for literal \u.
In other words, in Python 2.X this line is equivalent to:

    ('ellipsis', re.compile(r'\.{2,3}|u2026', re.UNICODE))

...which is certainly not what you wanted.

NB, the re.UNICODE flag affects only semantics of \w, \W, \b, \B, \d, \D, \s and \S, so it is no-op here.

The dubious regexp was found using pydiatra.

Activity

  1. self-assigned this
    on Feb 2, 2018
  2. akx commented on Jan 26, 2022

    @akx
    Member

    Babel no longer supports Python 2.x, so this is dealt with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions