Skip to content

Commit

Permalink
Make eaa64c0 more robust.
Browse files Browse the repository at this point in the history
This avoids crashing on ossfuzz, which uses a custom loader.
  • Loading branch information
aaugustin committed Jul 30, 2024
1 parent c8c0a9b commit d26bac4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/websockets/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def get_version(tag: str) -> str:
# Check that this file belongs to the installed package.
files = importlib.metadata.files("websockets")
if files:
version_file = [f for f in files if f.name == file_path.name][0]
if version_file.locate() == file_path:
return version
version_files = [f for f in files if f.name == file_path.name]
if version_files:
version_file = version_files[0]
if version_file.locate() == file_path:
return version

# Read version from git if available.
try:
Expand Down

0 comments on commit d26bac4

Please sign in to comment.