Brett Cannon added the comment:

I actually think this can be generalized thanks to some tweaks made in Python 
3.6 which will lead to it working with extension modules.

I need to double-check, but I think I can:
- Eliminate the _Module class (and thus have _LazyModule inherit 
types.ModuleType directly)
- Call create_module() and see if it returns something
- Use spec.loader_state to store the original value of module.__class__ 
(probably be simply storing __class__ in the dict of values)
- Just blindly try to set module.__class__ to _LazyModule and let the exception 
propagate if it fails
- In _LazyModule.__getattribute__, temporarily assign the type to 
types.ModuleType to shut off __getattribute__() before assigning the proper 
value

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26186>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to