Message195978
If I were to change this code in any way it would be to stop passing in a dummy value for fromlist, not stop pulling from sys.modules. The official idiom for directly calling __import__() is::
__import__(module_name)
return sys.modules[module_name]
It just so happens PyImport_Import() is old enough to be using both the old idiom of a bogus fromlist item *and* been updated at some point to use the new idiom.
I would also strongly discourage you from replacing __import__. More and more code is using importlib and various importers to do things and so it might have unforeseen consequences. importlib.import_module() also relies on importlib.__import__, not builtins.__import__ so as more code switches to that function for dynamic importing it will lead to more imports not using an overridden __import__. |
|
Date |
User |
Action |
Args |
2013-08-23 14:56:07 | brett.cannon | set | recipients:
+ brett.cannon, eric.snow, Rob Bairos |
2013-08-23 14:56:07 | brett.cannon | set | messageid: <1377269767.55.0.795949724261.issue18812@psf.upfronthosting.co.za> |
2013-08-23 14:56:07 | brett.cannon | link | issue18812 messages |
2013-08-23 14:56:07 | brett.cannon | create | |
|