From da823d2cade03ab6085a70ce0a6634116fbf3547 Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Sat, 6 Apr 2019 10:19:10 -0400 Subject: [PATCH] Fix a temporary-file crash --- NEWS.rst | 5 +++++ hy/importer.py | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 8fda6eb..f1d7447 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -12,6 +12,11 @@ New Features * Format strings with embedded Hy code (e.g., `f"The sum is {(+ x y)}"`) are now supported, even on Pythons earlier than 3.6. +Bug Fixes +------------------------------ +* Fixed a crash caused by errors creating temp files during bytecode + compilation + 0.16.0 ============================== diff --git a/hy/importer.py b/hy/importer.py index 0e59498..6d31004 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -467,9 +467,10 @@ else: if cfile is None: cfile = cache_from_source(filename) - f = tempfile.NamedTemporaryFile('wb', dir=os.path.split(cfile)[0], - delete=False) + f = None try: + f = tempfile.NamedTemporaryFile('wb', dir=os.path.split(cfile)[0], + delete=False) f.write('\0\0\0\0') f.write(struct.pack('