summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-25 21:55:43 (GMT)
committerGitHub <noreply@github.com>2019-07-25 21:55:43 (GMT)
commit0f211979c29109dcffc3039a24a9d3ecdfd900c9 (patch)
tree8ff48bcf8aa1703a77b4e86e08749081f54accac /PC
parentc594c274e92dc66afad02fe7a3c08a9b6c5a396d (diff)
downloadcpython-0f211979c29109dcffc3039a24a9d3ecdfd900c9.zip
cpython-0f211979c29109dcffc3039a24a9d3ecdfd900c9.tar.gz
cpython-0f211979c29109dcffc3039a24a9d3ecdfd900c9.tar.bz2
bpo-37641 preserve relative file location in embeddable zip (GH-14884)
Previously, pyc files in the embeddable distribution reported their location as <build path>/<file stem>.py. This causes a little confusion when interpreting stack traces as the file is in a (almost certainly) incorrect location, and lacks the full relative path to Lib (e.g. email/mime/image.py will only show image.py). This change preserves the Lib relative location of the source file as a path so that stack traces are (hopefully) less misleading and more informative. Co-Authored-By: Kyle Stanley <aeros167@gmail.com> (cherry picked from commit c4cda4369f4b8f33082890d16dfc364a90658ef6) Co-authored-by: Bill Collins <bilbocollins@gmail.com>
Diffstat (limited to 'PC')
-rw-r--r--PC/layout/main.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/PC/layout/main.py b/PC/layout/main.py
index 111f8aa..fe934bf 100644
--- a/PC/layout/main.py
+++ b/PC/layout/main.py
@@ -287,19 +287,18 @@ def _compile_one_py(src, dest, name, optimize, checked=True):
log_warning("Failed to compile {}", src)
return None
-
-def _py_temp_compile(src, ns, dest_dir=None, checked=True):
+# name argument added to address bpo-37641
+def _py_temp_compile(src, name, ns, dest_dir=None, checked=True):
if not ns.precompile or src not in PY_FILES or src.parent in DATA_DIRS:
return None
-
- dest = (dest_dir or ns.temp) / (src.stem + ".py")
+ dest = (dest_dir or ns.temp) / (src.stem + ".pyc")
return _compile_one_py(
- src, dest.with_suffix(".pyc"), dest, optimize=2, checked=checked
+ src, dest, name, optimize=2, checked=checked
)
def _write_to_zip(zf, dest, src, ns, checked=True):
- pyc = _py_temp_compile(src, ns, checked=checked)
+ pyc = _py_temp_compile(src, dest, ns, checked=checked)
if pyc:
try:
zf.write(str(pyc), dest.with_suffix(".pyc"))