diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org> | 2010-08-14 20:04:03 +0200 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org> | 2010-08-14 20:04:03 +0200 |
commit | f3fb3fb348dea23a857338c6397098453aad90ba (patch) | |
tree | 3d9e4fbd3a5b577139a32f098d498053ff28fbc0 | |
parent | 4b95add5d694f0b02936fad073dabf198728da12 (diff) | |
download | portage-f3fb3fb348dea23a857338c6397098453aad90ba.tar.gz portage-f3fb3fb348dea23a857338c6397098453aad90ba.tar.bz2 portage-f3fb3fb348dea23a857338c6397098453aad90ba.zip |
Use more correct paths to byte-compiled Python modules with Python 3.2
and remove empty __pycache__ directories.
-rw-r--r-- | pym/portage/tests/lint/test_compile_modules.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/pym/portage/tests/lint/test_compile_modules.py b/pym/portage/tests/lint/test_compile_modules.py index 2e5ab7e2d..5b86fcfb2 100644 --- a/pym/portage/tests/lint/test_compile_modules.py +++ b/pym/portage/tests/lint/test_compile_modules.py @@ -1,6 +1,7 @@ -# Copyright 2009 Gentoo Foundation +# Copyright 2009-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import imp import itertools import stat @@ -45,6 +46,18 @@ class CompileModulesTestCase(TestCase): do_compile = True cfile += '.py' if do_compile: - cfile += (__debug__ and 'c' or 'o') + try: + # Python >=3.2 + cfile = imp.cache_from_source(cfile) + except AttributeError: + cfile += (__debug__ and 'c' or 'o') py_compile.compile(x, cfile=cfile, doraise=True) os.unlink(cfile) + cfile_parent_dir = os.path.dirname(cfile) + if os.path.basename(cfile_parent_dir) == '__pycache__': + # Python >=3.2 + try: + os.rmdir(cfile_parent_dir) + except OSError: + # __pycache__ directory is non-empty. + pass |