]> git.pld-linux.org Git - packages/python3.git/blame - python3-bug11254.patch
- tar epoch
[packages/python3.git] / python3-bug11254.patch
CommitLineData
7dd2ca46 1diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
2--- a/Lib/distutils/tests/test_build_py.py
3+++ b/Lib/distutils/tests/test_build_py.py
4@@ -3,6 +3,7 @@
5 import os
6 import sys
7 import io
8+import imp
9 import unittest
10
11 from distutils.command.build_py import build_py
12@@ -57,9 +58,11 @@ class BuildPyTestCase(support.TempdirMan
13 self.assertEqual(len(cmd.get_outputs()), 3)
14 pkgdest = os.path.join(destination, "pkg")
15 files = os.listdir(pkgdest)
16- self.assertTrue("__init__.py" in files)
17- self.assertTrue("__init__.pyc" in files)
18- self.assertTrue("README.txt" in files)
19+ byte_compiled_files = os.listdir(os.path.join(pkgdest, "__pycache__"))
20+ self.assertIn("__init__.py", files)
21+ self.assertIn("__init__.{}.pyc".format(imp.get_tag()),
22+ byte_compiled_files)
23+ self.assertIn("README.txt", files)
24
25 def test_empty_package_dir (self):
26 # See SF 1668596/1720897.
27diff --git a/Lib/distutils/tests/test_install_lib.py b/Lib/distutils/tests/test_install_lib.py
28--- a/Lib/distutils/tests/test_install_lib.py
29+++ b/Lib/distutils/tests/test_install_lib.py
30@@ -1,6 +1,7 @@
31 """Tests for distutils.command.install_data."""
32 import sys
33 import os
34+import imp
35 import unittest
36
37 from distutils.command.install_lib import install_lib
38@@ -36,14 +37,19 @@ class InstallLibTestCase(support.Tempdir
39 'byte-compile not supported')
40 def test_byte_compile(self):
41 pkg_dir, dist = self.create_dist()
42+ cache_dir = os.path.join(pkg_dir, '__pycache__')
43 cmd = install_lib(dist)
44 cmd.compile = cmd.optimize = 1
45
46 f = os.path.join(pkg_dir, 'foo.py')
47 self.write_file(f, '# python file')
48 cmd.byte_compile([f])
49- self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
50- self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
51+ compiled_file = os.path.join(cache_dir,
52+ "foo.{}.pyc".format(imp.get_tag()))
53+ optimized_file = os.path.join(cache_dir,
54+ "foo.{}.pyo".format(imp.get_tag()))
55+ self.assertTrue(os.path.exists(compiled_file))
56+ self.assertTrue(os.path.exists(optimized_file))
57
58 def test_get_outputs(self):
59 pkg_dir, dist = self.create_dist()
60diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
61--- a/Lib/distutils/util.py
62+++ b/Lib/distutils/util.py
63@@ -6,7 +6,7 @@ one of the other *util.py modules.
64
65 __revision__ = "$Id$"
66
67-import sys, os, string, re
68+import sys, os, string, re, imp
69 from distutils.errors import DistutilsPlatformError
70 from distutils.dep_util import newer
71 from distutils.spawn import spawn
72@@ -533,7 +533,7 @@ byte_compile(files, optimize=%r, force=%
73 # Terminology from the py_compile module:
74 # cfile - byte-compiled file
75 # dfile - purported source filename (same as 'file' by default)
76- cfile = file + (__debug__ and "c" or "o")
77+ cfile = imp.cache_from_source(file, debug_override=not optimize)
78 dfile = file
79 if prefix:
80 if file[:len(prefix)] != prefix:
This page took 0.141457 seconds and 4 git commands to generate.