@@ -243,38 +243,41 @@ PyDoc_STRVAR(build_class_doc,
243243\n\
244244Internal helper function used by the class statement." );
245245
246+ /*[clinic input]
247+ __import__ as builtin___import__
248+
249+ name: object
250+ globals: object(c_default="NULL") = None
251+ locals: object(c_default="NULL") = None
252+ fromlist: object(c_default="NULL") = ()
253+ level: int = 0
254+
255+ Import a module.
256+
257+ Because this function is meant for use by the Python
258+ interpreter and not for general use, it is better to use
259+ importlib.import_module() to programmatically import a module.
260+
261+ The globals argument is only used to determine the context;
262+ they are not modified. The locals argument is unused. The fromlist
263+ should be a list of names to emulate ``from name import ...'', or an
264+ empty list to emulate ``import name''.
265+ When importing a module from a package, note that __import__('A.B', ...)
266+ returns package A when fromlist is empty, but its submodule B when
267+ fromlist is not empty. The level argument is used to determine whether to
268+ perform absolute or relative imports: 0 is absolute, while a positive number
269+ is the number of parent directories to search relative to the current module.
270+ [clinic start generated code]*/
271+
246272static PyObject *
247- builtin___import__ (PyObject * self , PyObject * args , PyObject * kwds )
273+ builtin___import___impl (PyObject * module , PyObject * name , PyObject * globals ,
274+ PyObject * locals , PyObject * fromlist , int level )
275+ /*[clinic end generated code: output=4febeda88a0cd245 input=35e9a6460412430f]*/
248276{
249- static char * kwlist [] = {"name" , "globals" , "locals" , "fromlist" ,
250- "level" , 0 };
251- PyObject * name , * globals = NULL , * locals = NULL , * fromlist = NULL ;
252- int level = 0 ;
253-
254- if (!PyArg_ParseTupleAndKeywords (args , kwds , "U|OOOi:__import__" ,
255- kwlist , & name , & globals , & locals , & fromlist , & level ))
256- return NULL ;
257277 return PyImport_ImportModuleLevelObject (name , globals , locals ,
258278 fromlist , level );
259279}
260280
261- PyDoc_STRVAR (import_doc ,
262- "__import__(name, globals=None, locals=None, fromlist=(), level=0) -> module\n\
263- \n\
264- Import a module. Because this function is meant for use by the Python\n\
265- interpreter and not for general use, it is better to use\n\
266- importlib.import_module() to programmatically import a module.\n\
267- \n\
268- The globals argument is only used to determine the context;\n\
269- they are not modified. The locals argument is unused. The fromlist\n\
270- should be a list of names to emulate ``from name import ...'', or an\n\
271- empty list to emulate ``import name''.\n\
272- When importing a module from a package, note that __import__('A.B', ...)\n\
273- returns package A when fromlist is empty, but its submodule B when\n\
274- fromlist is not empty. The level argument is used to determine whether to\n\
275- perform absolute or relative imports: 0 is absolute, while a positive number\n\
276- is the number of parent directories to search relative to the current module." );
277-
278281
279282/*[clinic input]
280283abs as builtin_abs
@@ -2903,7 +2906,7 @@ PyTypeObject PyZip_Type = {
29032906static PyMethodDef builtin_methods [] = {
29042907 {"__build_class__" , (PyCFunction )(void (* )(void ))builtin___build_class__ ,
29052908 METH_FASTCALL | METH_KEYWORDS , build_class_doc },
2906- { "__import__" , ( PyCFunction )( void ( * )( void )) builtin___import__ , METH_VARARGS | METH_KEYWORDS , import_doc },
2909+ BUILTIN___IMPORT___METHODDEF
29072910 BUILTIN_ABS_METHODDEF
29082911 BUILTIN_ALL_METHODDEF
29092912 BUILTIN_ANY_METHODDEF
0 commit comments