diff options
author | Nate Coraor <nate@bx.psu.edu> | 2016-02-01 15:39:10 -0500 |
---|---|---|
committer | Nate Coraor <nate@bx.psu.edu> | 2016-02-01 15:39:10 -0500 |
commit | e806fd536e9c22b40fa1781190bc09ab16505f82 (patch) | |
tree | 0668641d03cd57fbe5a500abd2a45310955c3bc3 | |
parent | 9b52a951828a0c1255684a22906f57dddb0d9f7c (diff) | |
download | wheel-e806fd536e9c22b40fa1781190bc09ab16505f82.tar.gz |
Use the file context manager when testing whether dependency_links.txt is empty
while converting from egg. Because the file is removed immediately after (if
empty), removal failed with PyPy on Windows because the file was not properly
closed.
-rw-r--r-- | wheel/bdist_wheel.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py index 2cb545d..eedc93d 100644 --- a/wheel/bdist_wheel.py +++ b/wheel/bdist_wheel.py @@ -372,9 +372,11 @@ class bdist_wheel(Command): 'not-zip-safe',))) # delete dependency_links if it is only whitespace - dependency_links = os.path.join(distinfo_path, 'dependency_links.txt') - if not open(dependency_links, 'r').read().strip(): - adios(dependency_links) + dependency_links_path = os.path.join(distinfo_path, 'dependency_links.txt') + with open(dependency_links_path, 'r') as dependency_links_file: + dependency_links = dependency_links_file.read().strip() + if not dependency_links: + adios(dependency_links_path) write_pkg_info(os.path.join(distinfo_path, 'METADATA'), pkg_info) |