Skip to content

Commit

Permalink
fixup! Don't leak compressed stream (piskvorky#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
ampanasiuk committed Aug 4, 2021
1 parent d70a7dc commit 46ea033
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions smart_open/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ def adapted_closer(adapter, adapted):

def close_both(*args):
nonlocal adapted
orig_close()
if adapted:
adapted.close()
adapted = None
try:
orig_close()
finally:
if adapted:
adapted, fp = None, adapted
fp.close()

adapter.close = close_both
return adapter
Expand Down

0 comments on commit 46ea033

Please sign in to comment.