Skip to content

Commit

Permalink
Fix #203: Handle name parsing of export entries correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Jul 17, 2023
1 parent a59c714 commit ac36501
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion distlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def __eq__(self, other):
__hash__ = object.__hash__


ENTRY_RE = re.compile(r'''(?P<name>(\w|[-.+])+)
ENTRY_RE = re.compile(r'''(?P<name>([^\[]\S*))
\s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
\s*(\[\s*(?P<flags>[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
''', re.VERBOSE)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def test_export_entry(self):
self.check_entry(get_export_entry('foo=abc'), 'foo', 'abc', None, [])
self.check_entry(get_export_entry('smc++ = smcpp.frontend:console'), 'smc++',
'smcpp.frontend', 'console', [])
# See issue #203 - correct name parsing to allow non-name-like names like ","
self.check_entry(get_export_entry(', = comma:main'), ',',
'comma', 'main', [])
self.check_entry(get_export_entry(',comma = comma:main'), ',comma',
'comma', 'main', [])

self.assertRaises(DistlibException, get_export_entry, 'foo=foo.bar:x:y')
self.assertRaises(DistlibException, get_export_entry, 'foo=foo.bar:x [')
self.assertRaises(DistlibException, get_export_entry, 'foo=foo.bar:x ]')
Expand Down

0 comments on commit ac36501

Please sign in to comment.