Skip to content

Commit 90e353a

Browse files
authored
Parse _version contents instead of using exec() (#259)
Signed-off-by: Alexander Piskun <[email protected]>
1 parent 5459857 commit 90e353a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

setup.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ class RequiredDependencyException(Exception):
2424

2525
def get_version():
2626
"""Returns version of the project."""
27-
version_file = "pillow_heif/_version.py"
28-
exec(compile(Path(version_file).read_text(encoding="utf-8"), version_file, "exec")) # pylint: disable=exec-used
29-
return locals()["__version__"]
27+
match = re.search(r'__version__\s*=\s*"(.*?)"', Path("pillow_heif/_version.py").read_text(encoding="utf-8"))
28+
return match.group(1)
3029

3130

3231
def _cmd_exists(cmd: str) -> bool:

0 commit comments

Comments
 (0)