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
e7ef8058
Kaydet (Commit)
e7ef8058
authored
Nis 04, 2014
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge of fix for issue #20942
üst
bcc17461
18fc4e70
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
32 deletions
+63
-32
import.rst
Doc/c-api/import.rst
+3
-0
NEWS
Misc/NEWS
+6
-0
import.c
Python/import.c
+54
-32
No files found.
Doc/c-api/import.rst
Dosyayı görüntüle @
e7ef8058
...
...
@@ -245,6 +245,9 @@ Importing Modules
.. versionadded:: 3.3
.. versionchanged:: 3.4
The ``__file__`` attribute is no longer set on the module.
.. c:function:: int PyImport_ImportFrozenModule(const char *name)
...
...
Misc/NEWS
Dosyayı görüntüle @
e7ef8058
...
...
@@ -144,6 +144,12 @@ IDLE
- Issue #17654: Ensure IDLE menus are customized properly on OS X for
non-framework builds and for all variants of Tk.
C API
-----
- Issue #20942: PyImport_ImportFrozenModuleObject() no longer sets __file__ to
match what importlib does; this affects _frozen_importlib as well as any
module loaded using imp.init_frozen().
Documentation
-------------
...
...
Python/import.c
Dosyayı görüntüle @
e7ef8058
...
...
@@ -837,12 +837,10 @@ error:
return
m
;
}
PyObject
*
PyImport_ExecCodeModuleObject
(
PyObject
*
name
,
PyObject
*
co
,
PyObject
*
pathname
,
PyObject
*
cpathname
)
static
PyObject
*
module_dict_for_exec
(
PyObject
*
name
)
{
PyObject
*
modules
=
PyImport_GetModuleDict
();
PyObject
*
m
,
*
d
,
*
v
;
PyObject
*
m
,
*
d
=
NULL
;
m
=
PyImport_AddModuleObject
(
name
);
if
(
m
==
NULL
)
...
...
@@ -852,9 +850,51 @@ PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname,
d
=
PyModule_GetDict
(
m
);
if
(
PyDict_GetItemString
(
d
,
"__builtins__"
)
==
NULL
)
{
if
(
PyDict_SetItemString
(
d
,
"__builtins__"
,
PyEval_GetBuiltins
())
!=
0
)
goto
error
;
PyEval_GetBuiltins
())
!=
0
)
{
remove_module
(
name
);
return
NULL
;
}
}
return
d
;
}
static
PyObject
*
exec_code_in_module
(
PyObject
*
name
,
PyObject
*
module_dict
,
PyObject
*
code_object
)
{
PyObject
*
modules
=
PyImport_GetModuleDict
();
PyObject
*
v
,
*
m
;
v
=
PyEval_EvalCode
(
code_object
,
module_dict
,
module_dict
);
if
(
v
==
NULL
)
{
remove_module
(
name
);
return
NULL
;
}
Py_DECREF
(
v
);
if
((
m
=
PyDict_GetItem
(
modules
,
name
))
==
NULL
)
{
PyErr_Format
(
PyExc_ImportError
,
"Loaded module %R not found in sys.modules"
,
name
);
return
NULL
;
}
Py_INCREF
(
m
);
return
m
;
}
PyObject
*
PyImport_ExecCodeModuleObject
(
PyObject
*
name
,
PyObject
*
co
,
PyObject
*
pathname
,
PyObject
*
cpathname
)
{
PyObject
*
d
,
*
v
;
d
=
module_dict_for_exec
(
name
);
if
(
d
==
NULL
)
{
return
NULL
;
}
if
(
pathname
!=
NULL
)
{
v
=
pathname
;
}
...
...
@@ -874,25 +914,7 @@ PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname,
if
(
PyDict_SetItemString
(
d
,
"__cached__"
,
v
)
!=
0
)
PyErr_Clear
();
/* Not important enough to report */
v
=
PyEval_EvalCode
(
co
,
d
,
d
);
if
(
v
==
NULL
)
goto
error
;
Py_DECREF
(
v
);
if
((
m
=
PyDict_GetItem
(
modules
,
name
))
==
NULL
)
{
PyErr_Format
(
PyExc_ImportError
,
"Loaded module %R not found in sys.modules"
,
name
);
return
NULL
;
}
Py_INCREF
(
m
);
return
m
;
error:
remove_module
(
name
);
return
NULL
;
return
exec_code_in_module
(
name
,
d
,
co
);
}
...
...
@@ -1206,7 +1228,7 @@ int
PyImport_ImportFrozenModuleObject
(
PyObject
*
name
)
{
const
struct
_frozen
*
p
;
PyObject
*
co
,
*
m
,
*
path
;
PyObject
*
co
,
*
m
,
*
d
;
int
ispackage
;
int
size
;
...
...
@@ -1235,7 +1257,7 @@ PyImport_ImportFrozenModuleObject(PyObject *name)
}
if
(
ispackage
)
{
/* Set __path__ to the empty list */
PyObject
*
d
,
*
l
;
PyObject
*
l
;
int
err
;
m
=
PyImport_AddModuleObject
(
name
);
if
(
m
==
NULL
)
...
...
@@ -1250,11 +1272,11 @@ PyImport_ImportFrozenModuleObject(PyObject *name)
if
(
err
!=
0
)
goto
err_return
;
}
path
=
PyUnicode_FromString
(
"<frozen>"
);
if
(
path
==
NULL
)
d
=
module_dict_for_exec
(
name
);
if
(
d
==
NULL
)
{
goto
err_return
;
m
=
PyImport_ExecCodeModuleObject
(
name
,
co
,
path
,
NULL
);
Py_DECREF
(
path
);
}
m
=
exec_code_in_module
(
name
,
d
,
co
);
if
(
m
==
NULL
)
goto
err_return
;
Py_DECREF
(
co
);
...
...
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