[Python-Dev] [Python-checkins] cpython (3.4): - Issue #22966: Fix __pycache__ pyc file name clobber when pyc_compile is
Barry Warsaw
barry at python.org
Tue Dec 2 17:28:49 CET 2014
On Dec 02, 2014, at 06:44 AM, Jeremy Kloth wrote:
>This test is failing on the Windows buildbots due to the hard-coded
>path separator. Using `os.pathsep` should work assuming that
>importlib returns normalized paths.
Good catch, thanks, however os.path would be the one to use. Here's the patch
that should fix it. This passes for me on Ubuntu, but I don't have a Windows
machine to do a test build on atm, so I'll just commit this and see how the
buildbots handle it.
diff -r 8badbd65840e Lib/test/test_py_compile.py
--- a/Lib/test/test_py_compile.py Tue Dec 02 09:24:06 2014 +0200
+++ b/Lib/test/test_py_compile.py Tue Dec 02 11:27:16 2014 -0500
@@ -106,9 +106,13 @@
weird_path = os.path.join(self.directory, 'foo.bar.py')
cache_path = importlib.util.cache_from_source(weird_path)
pyc_path = weird_path + 'c'
+ head, tail = os.path.split(cache_path)
+ penultimate_tail = os.path.basename(head)
self.assertEqual(
- '/'.join(cache_path.split('/')[-2:]),
- '__pycache__/foo.bar.{}.pyc'.format(sys.implementation.cache_tag))
+ os.path.join(penultimate_tail, tail),
+ os.path.join(
+ '__pycache__',
+ 'foo.bar.{}.pyc'.format(sys.implementation.cache_tag)))
with open(weird_path, 'w') as file:
file.write('x = 123\n')
py_compile.compile(weird_path)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20141202/a8e71e85/attachment.sig>
More information about the Python-Dev
mailing list