Fix a temporary-file crash
This commit is contained in:
parent
a3962ad19c
commit
da823d2cad
5
NEWS.rst
5
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
|
||||
==============================
|
||||
|
||||
|
@ -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('<I', timestamp))
|
||||
f.write(marshal.dumps(codeobject))
|
||||
@ -489,7 +490,8 @@ else:
|
||||
os.rename(f.name, cfile)
|
||||
except OSError:
|
||||
try:
|
||||
os.unlink(f.name)
|
||||
if f is not None:
|
||||
os.unlink(f.name)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user