Skip to content

Commit

Permalink
Don't swallow ImportError in temporary_directory() (#3037)
Browse files Browse the repository at this point in the history
Fixes #3026

If the context wrapped by the temporary_directory() context manager
raised ImportError (for example because distutils.util cannot be
imported, #721 #1837), it would previously keep going, causing a
RuntimeError from contextlib:

    RuntimeError: generator didn't stop after throw()

Co-authored-by: Remi Rampin <[email protected]>
  • Loading branch information
abn and remram44 authored Oct 2, 2020
1 parent 8e3f3c2 commit a2d2937
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions get-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ def colorize(style, text):
def temporary_directory(*args, **kwargs):
try:
from tempfile import TemporaryDirectory

with TemporaryDirectory(*args, **kwargs) as name:
yield name
except ImportError:
name = tempfile.mkdtemp(*args, **kwargs)

yield name

shutil.rmtree(name)
else:
with TemporaryDirectory(*args, **kwargs) as name:
yield name


def string_to_bool(value):
Expand Down

0 comments on commit a2d2937

Please sign in to comment.