Terry J. Reedy added the comment: (Import errors are runtime errors, not compile errors.)
After 'import lib2to3.pgen2', 'pgen2' in the code would not be valid. A 'from' import is needed instead. I fixed the import for 3.5/6 (but not 2.7), but the file still does not run. File "F:\Python\dev\35\lib\lib2to3\tests\pytree_idempotency.py", line 27, in main gr = driver.load_grammar("Grammar.txt") ,,, FileNotFoundError: [Errno 2] No such file or directory: 'Grammar.txt' After fixing this with def main(): - gr = driver.load_grammar("Grammar.txt") + gfile = os.path.dirname(os.path.dirname(__file__)) + "/Grammar.txt" + gr = driver.load_grammar(gfile) dr = driver.Driver(gr, convert=pytree.convert) the file fails with FileNotFoundError: [Errno 2] No such file or directory: 'example.py' There is no 'example.py in lib2to3. The closest is lib2to3/tests/data/fixers/parrot_example.py. At this point, I leave it Benjamin to fix the file so it runs or delete it. The file is not used anywhere since it is not part of the regular test suite (that would require the name to begin with 'test_'). It was meant to be run as a test by itself -- see the doc string. Perhaps the completion of 2to3 and the test suite made it obsolete. ---------- nosy: +terry.reedy stage: -> needs patch title: lib2to3/tests/pytree_idempotency.py has a broken import -> lib2to3/tests/pytree_idempotency.py does not run type: compile error -> behavior versions: +Python 2.7, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26911> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com