Re: [Python-Dev] [Python-checkins] cpython (3.4): - Issue #22966: Fix __pycache__ pyc file name clobber when pyc_compile is

2014年12月02日 08:33:57 -0800

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)

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to