Skip to content

Conversation

@warsaw
Copy link
Member

@warsaw warsaw commented Nov 21, 2017

This should be the last minor diff for bpo-31672

https://bugs.python.org/issue31672

# backward compatibility. So we use local -i flag and [a-zA-Z] pattern.
# See https://bugs.python.org/issue31672
idpattern = r'(?-i:[_a-zA-Z][_a-zA-Z0-9]*)'
idpattern = r'(?a:[_a-zA-Z][_a-zA-Z0-9]*)'
Copy link
Member

Choose a reason for hiding this comment

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

How about changing a-zA-Z to a-z?

Copy link
Member

Choose a reason for hiding this comment

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

And update the comment above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I don't think we can remove A-Z from the pattern because that could be seen as a backward compatibility break. E.g. what if there's code out there that sets flags=0? Then the regexp wouldn't be case-insensitive and the removal of A-Z would break that code.

I think it is safe to swap a for -i though, so I'll do that. I'll also update the comment and, as I just also noticed, the documentation.

Copy link
Member

Choose a reason for hiding this comment

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

This will just return the situation before the initial fix of this issue, but with correctly fixed bug. Initially the pattern was r'[_a-z][_a-z0-9]*', later it was changed to r'(?-i:[_a-zA-Z][_a-zA-Z0-9]*)', and now we can use r'(?a:[_a-z][_a-z0-9]*)' which is a fixed (ASCII-only) version of r'[_a-z][_a-z0-9]*'.

@warsaw warsaw merged commit e256b40 into python:master Nov 21, 2017
@warsaw warsaw deleted the bpo-31672 branch November 21, 2017 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants