Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d47a0a86
Kaydet (Commit)
d47a0a86
authored
Agu 14, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added Jim Fulton's PyImport_Import(), which calls whatever
__import__() hook is currently installed.
üst
6d8841c0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
import.c
Python/import.c
+78
-0
No files found.
Python/import.c
Dosyayı görüntüle @
d47a0a86
...
...
@@ -858,6 +858,84 @@ PyImport_ReloadModule(m)
}
/* Higher-level import emulator which emulates the "import" statement
more accurately -- it invokes the __import__() function from the
builtins of the current globals. This means that the import is
done using whatever import hooks are installed in the current
environment, e.g. by "ni" or "rexec". */
PyObject
*
PyImport_Import
(
module_name
)
PyObject
*
module_name
;
{
static
PyObject
*
silly_list
=
NULL
;
static
PyObject
*
builtins_str
=
NULL
;
static
PyObject
*
import_str
=
NULL
;
static
PyObject
*
standard_builtins
=
NULL
;
PyObject
*
globals
=
NULL
;
PyObject
*
import
=
NULL
;
PyObject
*
builtins
=
NULL
;
PyObject
*
r
=
NULL
;
/* Initialize constant string objects */
if
(
silly_list
==
NULL
)
{
import_str
=
PyString_InternFromString
(
"__import__"
);
if
(
import_str
==
NULL
)
return
NULL
;
builtins_str
=
PyString_InternFromString
(
"__builtins__"
);
if
(
builtins_str
==
NULL
)
return
NULL
;
silly_list
=
Py_BuildValue
(
"[s]"
,
"__doc__"
);
if
(
silly_list
==
NULL
)
return
NULL
;
}
/* Get the builtins from current globals */
globals
=
PyEval_GetGlobals
();
if
(
globals
!=
NULL
)
{
builtins
=
PyObject_GetItem
(
globals
,
builtins_str
);
if
(
builtins
==
NULL
)
goto
err
;
}
else
{
/* No globals -- use standard builtins, and fake globals */
PyErr_Clear
();
if
(
standard_builtins
==
NULL
)
{
standard_builtins
=
PyImport_ImportModule
(
"__builtin__"
);
if
(
standard_builtins
==
NULL
)
return
NULL
;
}
builtins
=
standard_builtins
;
Py_INCREF
(
builtins
);
globals
=
Py_BuildValue
(
"{OO}"
,
builtins_str
,
builtins
);
if
(
globals
==
NULL
)
goto
err
;
}
/* Get the __import__ function from the builtins */
if
(
PyDict_Check
(
builtins
))
import
=
PyObject_GetItem
(
builtins
,
import_str
);
else
import
=
PyObject_GetAttr
(
builtins
,
import_str
);
if
(
import
==
NULL
)
goto
err
;
/* Call the _import__ function with the proper argument list */
r
=
PyObject_CallFunction
(
import
,
"OOOO"
,
module_name
,
globals
,
globals
,
silly_list
);
err
:
Py_XDECREF
(
globals
);
Py_XDECREF
(
builtins
);
Py_XDECREF
(
import
);
return
r
;
}
/* Module 'imp' provides Python access to the primitives used for
importing modules.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment