Skip to content

Conversation

@methane
Copy link
Member

@methane methane commented Oct 13, 2017

Pattern [a-z] with IGNORECASE flag can match to some non-ASCII characters.

Straightforward solution for this is using IGNORECASE | ASCII flag.
But users may subclass Template and override only idpattern. So we want to
avoid changing Template.flags.

So this commit uses local flag -i for idpattern and change [a-z] to [a-zA-Z]..
(cherry picked from commit b22273e)

https://bugs.python.org/issue31672

…dentifiers (pythonGH-3872)

Pattern `[a-z]` with `IGNORECASE` flag can match to some non-ASCII characters.

Straightforward solution for this is using `IGNORECASE | ASCII` flag.
But users may subclass `Template` and override only `idpattern`. So we want to
avoid changing `Template.flags`.

So this commit uses local flag `-i` for `idpattern` and change `[a-z]` to `[a-zA-Z]`..
(cherry picked from commit b22273e)

While *flags* is kept to ``re.IGNORECASE`` for backward compatibility,
you can override it to ``0`` or ``re.IGNORECASE | re.ASCII`` when
subclassing. It's simple way to avoid unexpected match like above example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last sentence ("It's...") has some grammatical problems, and I don't think it's actually necessary. Can you remove it please?

@methane methane merged commit 7060380 into python:3.6 Oct 14, 2017
@methane methane deleted the backport-b22273e-3.6 branch October 14, 2017 05:22
methane added a commit to methane/cpython that referenced this pull request Oct 14, 2017
This sentence is removed while backporting to 3.6 branch.
See python#3982 (comment)
methane added a commit that referenced this pull request Oct 14, 2017
This sentence is removed while backporting to 3.6 branch.
See #3982 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants