This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mitchhentges
Recipients mitchhentges
Date 2021-04-28.20:36:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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/` was removed, and  `requests/` 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:52mitchhentgessetrecipients: + mitchhentges
2021-04-28 20:36:52mitchhentgessetmessageid: <>
2021-04-28 20:36:52mitchhentgeslinkissue43969 messages
2021-04-28 20:36:52mitchhentgescreate