changeset: 73773:661fb211f220 branch: 3.2 parent: 73768:bceb6aea8554 user: Meador Inge date: Mon Nov 28 09:27:32 2011 -0600 files: Lib/py_compile.py Lib/test/test_py_compile.py Misc/ACKS Misc/NEWS description: Issue #12618: py_compile cannot create files in current directory Initial patch by Sjoerd de Vries. diff -r bceb6aea8554 -r 661fb211f220 Lib/py_compile.py --- a/Lib/py_compile.py Sun Nov 27 12:49:27 2011 +0100 +++ b/Lib/py_compile.py Mon Nov 28 09:27:32 2011 -0600 @@ -130,7 +130,9 @@ else: cfile = imp.cache_from_source(file) try: - os.makedirs(os.path.dirname(cfile)) + dirname = os.path.dirname(cfile) + if dirname: + os.makedirs(dirname) except OSError as error: if error.errno != errno.EEXIST: raise diff -r bceb6aea8554 -r 661fb211f220 Lib/test/test_py_compile.py --- a/Lib/test/test_py_compile.py Sun Nov 27 12:49:27 2011 +0100 +++ b/Lib/test/test_py_compile.py Mon Nov 28 09:27:32 2011 -0600 @@ -39,6 +39,15 @@ py_compile.compile(self.source_path) self.assertTrue(os.path.exists(self.cache_path)) + def test_cwd(self): + cwd = os.getcwd() + os.chdir(self.directory) + py_compile.compile(os.path.basename(self.source_path), + os.path.basename(self.pyc_path)) + os.chdir(cwd) + self.assertTrue(os.path.exists(self.pyc_path)) + self.assertFalse(os.path.exists(self.cache_path)) + def test_relative_path(self): py_compile.compile(os.path.relpath(self.source_path), os.path.relpath(self.pyc_path)) diff -r bceb6aea8554 -r 661fb211f220 Misc/ACKS --- a/Misc/ACKS Sun Nov 27 12:49:27 2011 +0100 +++ b/Misc/ACKS Mon Nov 28 09:27:32 2011 -0600 @@ -941,6 +941,7 @@ Kurt Vile Norman Vine Frank Visser +Sjoerd de Vries Niki W. Waibel Wojtek Walczak Charles Waldman diff -r bceb6aea8554 -r 661fb211f220 Misc/NEWS --- a/Misc/NEWS Sun Nov 27 12:49:27 2011 +0100 +++ b/Misc/NEWS Mon Nov 28 09:27:32 2011 -0600 @@ -83,6 +83,9 @@ Library ------- +- Issue #12618: Fix a bug that prevented py_compile from creating byte + compiled files in the current directory. Initial patch by Sjoerd de Vries. + - Issue #13444: When stdout has been closed explicitly, we should not attempt to flush it at shutdown and print an error.

AltStyle によって変換されたページ (->オリジナル) /