summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-14 11:15:36 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-14 11:15:36 -0700
commit3dd3d6ce35a04d16c955931e3108fd5211f323a1 (patch)
tree835475281b3876a5368ee45c7995b41d8c9c608b
parentdf8fe2b2465df7af4f1f7fadba999ae9a1235d10 (diff)
parentf3fb3fb348dea23a857338c6397098453aad90ba (diff)
downloadportage-3dd3d6ce35a04d16c955931e3108fd5211f323a1.tar.gz
portage-3dd3d6ce35a04d16c955931e3108fd5211f323a1.tar.bz2
portage-3dd3d6ce35a04d16c955931e3108fd5211f323a1.zip
Merge branch 'master' of git+ssh://git.overlays.gentoo.org/proj/portage
-rw-r--r--pym/portage/tests/lint/test_compile_modules.py17
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