Skip to content

Commit d26bac4

Browse files
committed
Make eaa64c0 more robust.
This avoids crashing on ossfuzz, which uses a custom loader.
1 parent c8c0a9b commit d26bac4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/websockets/version.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ def get_version(tag: str) -> str:
4343
# Check that this file belongs to the installed package.
4444
files = importlib.metadata.files("websockets")
4545
if files:
46-
version_file = [f for f in files if f.name == file_path.name][0]
47-
if version_file.locate() == file_path:
48-
return version
46+
version_files = [f for f in files if f.name == file_path.name]
47+
if version_files:
48+
version_file = version_files[0]
49+
if version_file.locate() == file_path:
50+
return version
4951

5052
# Read version from git if available.
5153
try:

0 commit comments

Comments
 (0)