Message392254
Python 3 imports may fail if a Python 2 .pyc file exists without an accompanying .py file.
-----
My project vendors code, and we recently updated "requests" to a drastically newer version.
As part of this version change, `requests/packages/__init__.py` was removed, and `requests/packages.py` was added.
This project is long-lived, and many people have imported `requests` with Python 2. So, `requests/packages/__init__.pyc` exists.
After making this update, importing requests with Python 3 fails:
`ImportError: bad magic number in 'parent.child': b'\x03\xf3\r\n'`
Interestingly, deleting `requests/packages/__init__.pyc` allows Python 3 to work again.
-----
I've attached a "reproduction" script that produces the directory structure and tweak required to cause the failure.
I'm running Python 2.7.18 and Python 3.9.1. |
|
Date |
User |
Action |
Args |
2021-04-28 20:36:52 | mitchhentges | set | recipients:
+ mitchhentges |
2021-04-28 20:36:52 | mitchhentges | set | messageid: <1619642212.93.0.461785778702.issue43969@roundup.psfhosted.org> |
2021-04-28 20:36:52 | mitchhentges | link | issue43969 messages |
2021-04-28 20:36:52 | mitchhentges | create | |
|