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.

Title: import C API mess
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.2
Status: closed Resolution: fixed
Dependencies: 2377 Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon
Priority: normal Keywords:

Created on 2003-01-14 15:02 by gvanrossum, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (4)
msg60301 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-01-14 15:02
There are too many different C-level APIs for importing
a module.

Many of them have the nasty property that they can try
to do a relative import in the context of the nearest
Python stack frame, where that is not what the C code

This needs to be cleaned up.

Example use case: time.strptime() is now a C wrapper
that imports the _strptime module; but if you follow
the path it takes to import, it's quite an amazing
journey. It should cut all of that short by looking in
sys.modules['_strptime'] first. (But what about
restricted execution? Well ought to be safe.)
msg63892 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 05:04
Brett, perhaps you can consider this with your integration of
import-rewritten-in-Python?  I think it's fine to leave this alone for 2.6.
msg63896 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-03-18 05:40
I was planning to do that in order to make my life simpler when I have
to re-implement the C API.
msg175766 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-17 16:14
The story of impports from the C level is much more sane than back in the 2.6 days thanks to PyImport_Import, PyImport_ImportModuleLevelObject, and PyImport_ImportModuleLevel.
Date User Action Args
2022-04-10 16:06:08adminsetgithub: 37769
2012-11-17 16:14:07brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg175766

stage: needs patch -> resolved
2011-06-27 00:36:10brett.cannonsetdependencies: + Replace __import__ w/ importlib.__import__
2010-08-17 23:59:43gvanrossumsetnosy: - gvanrossum
2010-08-17 22:55:24BreamoreBoysetstage: needs patch
type: enhancement
versions: + Python 3.2, - Python 3.0
2008-03-18 05:40:10brett.cannonsetmessages: + msg63896
2008-03-18 05:04:56gvanrossumsetassignee: gvanrossum -> brett.cannon
messages: + msg63892
nosy: + brett.cannon
components: + Interpreter Core, - None
versions: + Python 3.0
2003-01-14 15:02:56gvanrossumcreate