summaryrefslogtreecommitdiffstats
path: root/Lib/py_compile.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-04-14 16:48:15 (GMT)
committerBrett Cannon <brett@python.org>2013-04-14 16:48:15 (GMT)
commitedfd6ae79c76ebf766ffc1da1e8003ab72df6475 (patch)
tree7c7387f82f4e909e0a96b3e6a82d7f7e3e475156 /Lib/py_compile.py
parent672559fc4f6d3811440965a12d900209f364b5f0 (diff)
downloadcpython-edfd6ae79c76ebf766ffc1da1e8003ab72df6475.zip
cpython-edfd6ae79c76ebf766ffc1da1e8003ab72df6475.tar.gz
cpython-edfd6ae79c76ebf766ffc1da1e8003ab72df6475.tar.bz2
Issue #17244: Don't mask exceptions raised during the creation of
bytecode files in py_compile. Thanks to Arfrever Frehtes Taifersar Arahesis for the bug report.
Diffstat (limited to 'Lib/py_compile.py')
-rw-r--r--Lib/py_compile.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index d255a2d..701e8ac 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -106,7 +106,7 @@ def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
source_bytes = loader.get_data(file)
try:
code = loader.source_to_code(source_bytes, dfile or file,
- _optimize=optimize)
+ _optimize=optimize)
except Exception as err:
py_exc = PyCompileError(err.__class__, err, dfile or file)
if doraise:
@@ -121,11 +121,13 @@ def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
except FileExistsError:
pass
source_stats = loader.path_stats(file)
- bytecode = importlib._bootstrap._code_to_bytecode(code,
- source_stats['mtime'], len(source_bytes))
- loader._cache_bytecode(file, cfile, bytecode)
+ bytecode = importlib._bootstrap._code_to_bytecode(
+ code, source_stats['mtime'], source_stats['size'])
+ mode = importlib._bootstrap._calc_mode(file)
+ importlib._bootstrap._write_atomic(cfile, bytecode, mode)
return cfile
+
def main(args=None):
"""Compile several source files.