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 brett.cannon
Recipients Rob Bairos, brett.cannon, eric.snow
Date 2013-08-23.14:56:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1377269767.55.0.795949724261.issue18812@psf.upfronthosting.co.za>
In-reply-to
Content
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__.
History
Date User Action Args
2013-08-23 14:56:07brett.cannonsetrecipients: + brett.cannon, eric.snow, Rob Bairos
2013-08-23 14:56:07brett.cannonsetmessageid: <1377269767.55.0.795949724261.issue18812@psf.upfronthosting.co.za>
2013-08-23 14:56:07brett.cannonlinkissue18812 messages
2013-08-23 14:56:07brett.cannoncreate