Martin Panter added the comment: Patch v4 just uses an explicit encoding in the test suite rather than relying on the environment’s encoding.
Laura: I think my patch may already handle your case. Assuming this is one way to reproduce it: $ mkdir test $ : > test/__init__.py $ python2 -c 'import test' $ rm test/__init__.py $ ./python -m test /media/disk/home/proj/python/cpython/python: Error while finding spec for 'test.__main__' (<class 'ImportError'>: bad magic number in 'test': b'\x03\xf3\r\n'); 'test' is a package and cannot be directly executed [Exit 1] $ hg qpush --move issue_19771_runpy.patch.v4 applying issue_19771_runpy.patch.v4 now at: issue_19771_runpy.patch.v4 $ ./python -m test /media/disk/home/proj/python/cpython/python: Error while finding spec for 'test.__main__' (ImportError: bad magic number in 'test': b'\x03\xf3\r\n') [Exit 1] Perhaps the error could be improved further, though. I guess the problem is there is a bad magic number in test/__init__.pyc. And I have no idea what the “finding spec” bit is about; it is meaningless noise to me. ---------- Added file: http://bugs.python.org/file40150/issue_19771_runpy.patch.v4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19771> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com