You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/brettcannon'closed_at=<Date2012-11-17.16:14:07.136>created_at=<Date2003-01-14.15:02:56.000>labels= ['interpreter-core', 'type-feature']
title='import C API mess'updated_at=<Date2012-11-17.16:14:07.134>user='https://github.com/gvanrossum'
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
intended.
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 _strptime.py ought to be safe.)
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.
Activity
gvanrossum commentedon Jan 14, 2003
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
intended.
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 _strptime.py ought to be safe.)
gvanrossum commentedon Mar 18, 2008
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.
brettcannon commentedon Mar 18, 2008
I was planning to do that in order to make my life simpler when I have
to re-implement the C API.
brettcannon commentedon Nov 17, 2012
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.