Skip to content

Commit

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

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

    RuntimeError: generator didn't stop after throw()
  • Loading branch information
remram44 authored and abn committed Oct 1, 2020
1 parent d673342 commit 7a5f260
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 7a5f260

Please sign in to comment.