On 6/3/2021 7:42 PM, Senthil Kumaran wrote:
On Thu, Jun 03, 2021 at 07:08:06PM +0100, Robin Becker wrote:
The regression may well be a platform issue. I am by no means an expert at
building python; I followed a recipe from the ARCH PKGBUILD of some time

I meant the change in the diff we were suspecting was supposed to be
"Windows" specific. But interesting that it was observed in ARCH. The
non-windows piece of changes were probably responsible

While we were investigating the reliably broken behaviour, we figured that related behaviour was *unreliably* broken on all platforms.

Specifically, if you imported a module through a relative path (resolved to CWD), changed the CWD, cleared the module cache, and reimported, you would still get the original module, contrary to the intent of getting the newly resolved module. ("Correct" code would have also cleared the import path caches, not just sys.modules.) This was because the module info was cached using the relative path, and so would be used later even though its absolute path had changed.

Someone reported this change in 3.8 and we decided to revert it in existing released, because the bugfix was for an obscure enough situation that it really wasn't worth breaking any existing versions. For unreleased versions, it's better to fix it so that imports will be more reliable in the future.

Based on Robin's original post, it looks like this is exactly the scenario we wanted to fix, and it's probably exposed an underlying issue in that test suite.

Unfortunately, import caching has changed a lot since Python 2.7, so it's very unlikely that one approach will be able to do reliable reloading across all of those versions. Your best bet since 3.3 is to use the importlib module's methods (but your *best* bet overall is to run separate test suites in their own process so you can avoid the CWD changes).

Cheers,
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/RDIMZA2KVWZSYUVLWQUZT4TE5BH6QWOV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to