mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-16 03:02:37 +03:00
Use context manager in get_version function for better file handling
This commit is contained in:
parent
32dbd3525d
commit
0a1a82f2b3
3
setup.py
3
setup.py
|
@ -43,7 +43,8 @@ def get_version(package):
|
|||
"""
|
||||
Return package version as listed in `__version__` in `init.py`.
|
||||
"""
|
||||
init_py = open(os.path.join(package, '__init__.py')).read()
|
||||
with open(os.path.join(package, '__init__.py'), encoding='utf-8') as f:
|
||||
init_py = f.read()
|
||||
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user