Skip to content

Fix invalid regex for entry point names#695

Merged
di merged 1 commit intopypa:masterfrom
randomir:fix-entry_points-typo
Feb 11, 2020
Merged

Fix invalid regex for entry point names#695
di merged 1 commit intopypa:masterfrom
randomir:fix-entry_points-typo

Conversation

@randomir
Copy link
Contributor

Closes #694.

@webknjaz
Copy link
Member

Why?

@randomir
Copy link
Contributor Author

@webknjaz, see #694. The regex is not valid.

@webknjaz
Copy link
Member

I saw that. Still, it doesn't explain why you consider it invalid. Looks ok to me.

@randomir
Copy link
Contributor Author

Try compiling it.

@randomir
Copy link
Contributor Author

Check the ERE specs, section on Bracket Expression, near the end of the section:

The hyphen character will be treated as itself if it occurs first (after an initial ^, if any) or last in the list, or as an ending range point in a range expression. As examples, the expressions [-ac] and [ac-] are equivalent and match any of the characters a, c or -; [^-ac] and [^ac-] are equivalent and match any characters except a, c or -; the expression [%--] matches any of the characters between % and - inclusive; the expression [--@] matches any of the characters between - and @ inclusive; and the expression [a--@] is invalid, because the letter a follows the symbol - in the POSIX locale. To use a hyphen as the starting range point, it must either come first in the bracket expression or be specified as a collating symbol, for example: [][.-.]-0], which matches either a right bracket or any character or collating element that collates between hyphen and 0, inclusive.

@webknjaz
Copy link
Member

Okay, I see now. For the future, it's a good idea to explain things in the PR description and/or issue because if it's obvious to you it doesn't mean that it's obvious to everyone else. You just caused me to ask for the explanation twice and only then hinted to run something in the interpreter which could've been included in the very first post and would save us both (and any other reviewer) a lot of time.

I'll post the log here so that nobody would need to repeat these steps to figure out what you mean:

In [1]: import re

In [2]: re.compile('[\w-.]+')
[...]
error: bad character range \w-. at position 1

@randomir
Copy link
Contributor Author

@webknjaz, sure I always do that for non-obvious bugs. This one seemed like an obvious typo to me. Sorry.

@di di merged commit 70ba3e4 into pypa:master Feb 11, 2020
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

Nice catch!

@pradyunsg
Copy link
Member

Ahahaha. @di beat me to the merge button. ;)

@randomir randomir deleted the fix-entry_points-typo branch February 11, 2020 18:33
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.

Regex for entry point name is invalid

4 participants