No worries, I actually seem to have solved the immediately pressing problem that was blocking PEP 615 by doing this:

def get_modules():
    import zoneinfo as c_module
    py_module = import_fresh_module("zoneinfo", blocked=["_czoneinfo"])

    return py_module, c_module

I'll have to dig in to figure out exactly why that works, and why it doesn't work in the reference implementation (which has the the C implementation living at `zoneinfo._czoneinfo` instead of at `_czoneinfo`), and hopefully that will shed some light on the other issues. For the moment I've got something that appears to work and a suggestive pattern of behavior as to why it wasn't working, so that actually seems like it will help me solve my short term goal of getting zoneinfo merged ASAP and my long term goal of ensuring that the tests are robust.


On 5/6/20 3:55 PM, Brett Cannon wrote:
I'm drowning in work this month, so if you need me to look at something then I unfortunately need a point-blank link of what you want me to look at with a targeted question.

As for import_fresh_module() not being robust: of course it isn't because it's mucking with import stuff in a very non-standard way. 😉 All it's doing is an import and clearing the module from sys.modules. The extras it provides is to shove None into sys.modules to trigger an ImportError and so you can block any acceleration module from being imported and to forcibly use the Python code. That's it.
Python-Dev mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct: