xref: /mports/lang/python311/files/patch-Lib_distutils_command_install__lib.py
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 9934ce31b8447667f71c211e559a8de71e8263db Mon Sep 17 00:00:00 2001
2From: Brendan Molloy <brendan@bbqsrc.net>
3Date: Mon, 4 Jan 2016 23:14:06 +1100
4Subject: [PATCH] Check bytecode file actually exists and tests
5
6Should solve issue 20397, where using the --record argument results
7in files that failed to generate bytecode files are added to the
8record file nonetheless.
9---
10 Lib/distutils/command/install_lib.py    | 17 +++++++++++++----
11 Lib/distutils/tests/test_install_lib.py |  8 ++++++--
12 2 files changed, 19 insertions(+), 6 deletions(-)
13
14--- Lib/distutils/command/install_lib.py.orig	2015-12-07 01:39:07 UTC
15+++ Lib/distutils/command/install_lib.py
16@@ -164,12 +164,21 @@ class install_lib(Command):
17             ext = os.path.splitext(os.path.normcase(py_file))[1]
18             if ext != PYTHON_SOURCE_EXTENSION:
19                 continue
20+
21             if self.compile:
22-                bytecode_files.append(importlib.util.cache_from_source(
23-                    py_file, optimization=''))
24+                candidate = importlib.util.cache_from_source(
25+                    py_file, optimization='')
26+
27+                if os.path.isfile(candidate):
28+                    bytecode_files.append(candidate)
29+
30             if self.optimize > 0:
31-                bytecode_files.append(importlib.util.cache_from_source(
32-                    py_file, optimization=self.optimize))
33+                candidate = importlib.util.cache_from_source(
34+                    py_file, optimization=self.optimize)
35+
36+                if os.path.isfile(candidate):
37+                    bytecode_files.append(candidate)
38+
39
40         return bytecode_files
41
42

served by {OpenGrok

Last Index Update: Sun Mar 22 17:06:33 EDT 2026