mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
bugfix: f.close() only required if open succeeded
when open fails, instead of raising the original error, the "f.close()" was erroring in the final clause.
This commit is contained in:
parent
5707a39df6
commit
a7ad636dab
@ -309,6 +309,7 @@ def parse_requirements(file_):
|
||||
logging.error("Failed on file: {}".format(file_))
|
||||
raise
|
||||
else:
|
||||
try:
|
||||
data = [x.strip() for x in f.readlines() if x != "\n"]
|
||||
finally:
|
||||
f.close()
|
||||
@ -375,6 +376,7 @@ def clean(file_, imports):
|
||||
logging.error("Failed on file: {}".format(file_))
|
||||
raise
|
||||
else:
|
||||
try:
|
||||
for i in f.readlines():
|
||||
if re_remove.match(i) is None:
|
||||
to_write.append(i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user