Merge pull request #1767 from nixy/master

Allow Hy to run when installed in read only filesystem
This commit is contained in:
Kodi Arfer 2019-04-06 15:46:03 -04:00 committed by GitHub
commit 57326785b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -89,4 +89,5 @@
* Simon Gomizelj <simon@vodik.xyz>
* Yigong Wang <wang@yigo.ng>
* Oskar Kvist <oskar.kvist@gmail.com>
* Brandon T. Willard <brandonwillard@gmail.com>
* Brandon T. Willard <brandonwillard@gmail.com>
* Andrew R. M. <nixy@nixy.moe>

View File

@ -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
==============================

View File

@ -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