Skip to content

Commit

Permalink
Fix edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldoussoren committed Apr 21, 2022
1 parent 198017f commit 51179bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion py2app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def find_version(fn: os.PathLike) -> typing.Optional[str]:
# would require handling encoding tokens.
source = stream.read()

module_ast = ast.parse(source, fn)
module_ast = ast.parse(source, str(fn))

# Look for a toplevel assignment statement that sets
# __version__ to a constant value
Expand All @@ -172,6 +172,8 @@ def find_version(fn: os.PathLike) -> typing.Optional[str]:
continue

for t in node.targets:
if not isinstance(t, ast.Name):
continue
if t.id == "__version__":
value = node.value
if isinstance(value, ast.Constant) and isinstance(value.value, str):
Expand Down
3 changes: 3 additions & 0 deletions py2app_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_multi_part(self):
def test_multi_target(self):
self.assert_version_equals("b = __version__ = 'c'", "c")

def test_multi_target2(self):
self.assert_version_equals("b[x] = __version__ = 'c'", "c")

def test_not_string(self):
self.assert_version_equals("__version__ = 42", None)

Expand Down

0 comments on commit 51179bd

Please sign in to comment.