diff -r 4b64a049f451 Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py Fri Aug 19 12:00:13 2016 +0300 +++ b/Lib/test/test_compileall.py Wed Sep 07 16:59:51 2016 +1000 @@ -115,7 +115,16 @@ except ValueError: pass - self.assertTrue(compileall.compile_path(quiet=2)) + # issue27322: Prevent spurious failures due to permissions + # Attempt to compile only those directories which are part of the + # current binary's subtree. For example, if Python is being run from + # the build directory (eg 'make test'), ignore all system paths. + basedir = os.path.dirname(sys.executable) + if basedir.endswith('/bin'): + basedir = os.path.dirname(basedir) + sys.path = [p for p in sys.path if p.startswith(basedir)] + + self.assertTrue(compileall.compile_path(quiet=2, force=True)) with test.test_importlib.util.import_state(path=[self.directory]): self.add_bad_source_file()