Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
86b7afdf
Commit
86b7afdf
authored
Sep 04, 2017
by
Eric Snow
Committed by
GitHub
Sep 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-28411: Remove "modules" field from Py_InterpreterState. (#1638)
sys.modules is the one true source.
parent
f5ea83f4
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
261 additions
and
111 deletions
+261
-111
Doc/c-api/import.rst
Doc/c-api/import.rst
+7
-0
Doc/whatsnew/3.7.rst
Doc/whatsnew/3.7.rst
+3
-0
Include/import.h
Include/import.h
+22
-3
Include/modsupport.h
Include/modsupport.h
+4
-0
Include/pystate.h
Include/pystate.h
+0
-1
Misc/NEWS.d/next/Core and Builtins/2017-09-04-10-46-09.bpo-28411.IU9rQL.rst
...ore and Builtins/2017-09-04-10-46-09.bpo-28411.IU9rQL.rst
+4
-0
Modules/_pickle.c
Modules/_pickle.c
+2
-10
Modules/pyexpat.c
Modules/pyexpat.c
+2
-8
Objects/moduleobject.c
Objects/moduleobject.c
+9
-3
Objects/typeobject.c
Objects/typeobject.c
+1
-2
Python/_warnings.c
Python/_warnings.c
+1
-4
Python/bltinmodule.c
Python/bltinmodule.c
+1
-1
Python/ceval.c
Python/ceval.c
+1
-1
Python/import.c
Python/import.c
+168
-37
Python/importdl.c
Python/importdl.c
+2
-1
Python/pylifecycle.c
Python/pylifecycle.c
+32
-34
Python/pystate.c
Python/pystate.c
+0
-2
Python/sysmodule.c
Python/sysmodule.c
+2
-4
No files found.
Doc/c-api/import.rst
View file @
86b7afdf
...
...
@@ -204,6 +204,13 @@ Importing Modules
Return the dictionary used for the module administration (a.k.a.
``sys.modules``). Note that this is a per-interpreter variable.
.. c:function:: PyObject* PyImport_GetModule(PyObject *name)
Return the already imported module with the given name. If the
module has not been imported yet then returns NULL but does not set
an error. Returns NULL and sets an error if the lookup failed.
.. versionadded:: 3.7
.. c:function:: PyObject* PyImport_GetImporter(PyObject *path)
...
...
Doc/whatsnew/3.7.rst
View file @
86b7afdf
...
...
@@ -456,6 +456,9 @@ Changes in the Python API
and module are affected by this change. (Contributed by INADA Naoki and
Eugene Toder in :issue:`29463`.)
* ``PyInterpreterState`` no longer has a ``modules`` field. Instead use
``sys.modules``.
* The *mode* argument of :func:`os.makedirs` no longer affects the file
permission bits of newly-created intermediate-level directories.
To set their file permission bits you can set the umask before invoking
...
...
Include/import.h
View file @
86b7afdf
...
...
@@ -38,11 +38,25 @@ PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
);
#endif
PyAPI_FUNC
(
PyObject
*
)
PyImport_GetModuleDict
(
void
);
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
int
)
_PyImport_IsInitialized
(
PyInterpreterState
*
);
#endif
PyAPI_FUNC
(
PyObject
*
)
PyImport_GetModule
(
PyObject
*
name
);
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
_PyImport_GetModule
(
PyObject
*
name
);
PyAPI_FUNC
(
PyObject
*
)
_PyImport_GetModuleWithError
(
PyObject
*
name
);
PyAPI_FUNC
(
PyObject
*
)
_PyImport_GetModuleId
(
struct
_Py_Identifier
*
name
);
PyAPI_FUNC
(
int
)
_PyImport_SetModule
(
PyObject
*
name
,
PyObject
*
module
);
PyAPI_FUNC
(
int
)
_PyImport_SetModuleString
(
const
char
*
name
,
PyObject
*
module
);
#endif
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
PyAPI_FUNC
(
PyObject
*
)
PyImport_AddModuleObject
(
PyObject
*
name
);
#endif
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
_PyImport_AddModuleObject
(
PyObject
*
,
PyObject
*
);
#endif
PyAPI_FUNC
(
PyObject
*
)
PyImport_AddModule
(
const
char
*
name
/* UTF-8 encoded string */
);
...
...
@@ -97,14 +111,19 @@ PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
PyAPI_FUNC
(
void
)
_PyImport_ReInitLock
(
void
);
PyAPI_FUNC
(
PyObject
*
)
_PyImport_FindBuiltin
(
const
char
*
name
/* UTF-8 encoded string */
const
char
*
name
,
/* UTF-8 encoded string */
PyObject
*
modules
);
PyAPI_FUNC
(
PyObject
*
)
_PyImport_FindExtensionObject
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
_PyImport_FindExtensionObjectEx
(
PyObject
*
,
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
int
)
_PyImport_FixupBuiltin
(
PyObject
*
mod
,
const
char
*
name
/* UTF-8 encoded string */
const
char
*
name
,
/* UTF-8 encoded string */
PyObject
*
modules
);
PyAPI_FUNC
(
int
)
_PyImport_FixupExtensionObject
(
PyObject
*
,
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
int
)
_PyImport_FixupExtensionObject
(
PyObject
*
,
PyObject
*
,
PyObject
*
,
PyObject
*
);
struct
_inittab
{
const
char
*
name
;
/* ASCII encoded string */
...
...
Include/modsupport.h
View file @
86b7afdf
...
...
@@ -191,6 +191,10 @@ PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
PyAPI_FUNC
(
PyObject
*
)
PyModule_Create2
(
struct
PyModuleDef
*
,
int
apiver
);
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
PyObject
*
)
_PyModule_CreateInitialized
(
struct
PyModuleDef
*
,
int
apiver
);
#endif
#ifdef Py_LIMITED_API
#define PyModule_Create(module) \
...
...
Include/pystate.h
View file @
86b7afdf
...
...
@@ -52,7 +52,6 @@ typedef struct _is {
int64_t
id
;
PyObject
*
modules
;
PyObject
*
modules_by_index
;
PyObject
*
sysdict
;
PyObject
*
builtins
;
...
...
Misc/NEWS.d/next/Core and Builtins/2017-09-04-10-46-09.bpo-28411.IU9rQL.rst
0 → 100644
View file @
86b7afdf
``PyInterpreterState`` has a "modules" field that is copied into
``sys.modules`` during interpreter startup. This causes problems if a
program replaces ``sys.modules`` with something else. To solve this we
eliminate ``PyInterpreterState.modules``.
Modules/_pickle.c
View file @
86b7afdf
...
...
@@ -6418,9 +6418,7 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self,
/*[clinic end generated code: output=becc08d7f9ed41e3 input=e2e6a865de093ef4]*/
{
PyObject
*
global
;
PyObject
*
modules_dict
;
PyObject
*
module
;
_Py_IDENTIFIER
(
modules
);
/* Try to map the old names used in Python 2.x to the new ones used in
Python 3.x. We do this only with old pickle protocols and when the
...
...
@@ -6477,13 +6475,7 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self,
}
}
modules_dict
=
_PySys_GetObjectId
(
&
PyId_modules
);
if
(
modules_dict
==
NULL
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"unable to get sys.modules"
);
return
NULL
;
}
module
=
PyDict_GetItemWithError
(
modules_dict
,
module_name
);
module
=
PyImport_GetModule
(
module_name
);
if
(
module
==
NULL
)
{
if
(
PyErr_Occurred
())
return
NULL
;
...
...
@@ -6491,11 +6483,11 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self,
if
(
module
==
NULL
)
return
NULL
;
global
=
getattribute
(
module
,
global_name
,
self
->
proto
>=
4
);
Py_DECREF
(
module
);
}
else
{
global
=
getattribute
(
module
,
global_name
,
self
->
proto
>=
4
);
}
Py_DECREF
(
module
);
return
global
;
}
...
...
Modules/pyexpat.c
View file @
86b7afdf
...
...
@@ -1643,7 +1643,6 @@ MODULE_INITFUNC(void)
PyObject
*
errors_module
;
PyObject
*
modelmod_name
;
PyObject
*
model_module
;
PyObject
*
sys_modules
;
PyObject
*
tmpnum
,
*
tmpstr
;
PyObject
*
codes_dict
;
PyObject
*
rev_codes_dict
;
...
...
@@ -1693,11 +1692,6 @@ MODULE_INITFUNC(void)
*/
PyModule_AddStringConstant
(
m
,
"native_encoding"
,
"UTF-8"
);
sys_modules
=
PySys_GetObject
(
"modules"
);
if
(
sys_modules
==
NULL
)
{
Py_DECREF
(
m
);
return
NULL
;
}
d
=
PyModule_GetDict
(
m
);
if
(
d
==
NULL
)
{
Py_DECREF
(
m
);
...
...
@@ -1707,7 +1701,7 @@ MODULE_INITFUNC(void)
if
(
errors_module
==
NULL
)
{
errors_module
=
PyModule_New
(
MODULE_NAME
".errors"
);
if
(
errors_module
!=
NULL
)
{
PyDict_SetItem
(
sys_modules
,
errmod_name
,
errors_module
);
_PyImport_SetModule
(
errmod_name
,
errors_module
);
/* gives away the reference to errors_module */
PyModule_AddObject
(
m
,
"errors"
,
errors_module
);
}
...
...
@@ -1717,7 +1711,7 @@ MODULE_INITFUNC(void)
if
(
model_module
==
NULL
)
{
model_module
=
PyModule_New
(
MODULE_NAME
".model"
);
if
(
model_module
!=
NULL
)
{
PyDict_SetItem
(
sys_modules
,
modelmod_name
,
model_module
);
_PyImport_SetModule
(
modelmod_name
,
model_module
);
/* gives away the reference to model_module */
PyModule_AddObject
(
m
,
"model"
,
model_module
);
}
...
...
Objects/moduleobject.c
View file @
86b7afdf
...
...
@@ -160,12 +160,18 @@ _add_methods_to_object(PyObject *module, PyObject *name, PyMethodDef *functions)
PyObject
*
PyModule_Create2
(
struct
PyModuleDef
*
module
,
int
module_api_version
)
{
if
(
!
_PyImport_IsInitialized
(
PyThreadState_GET
()
->
interp
))
Py_FatalError
(
"Python import machinery not initialized"
);
return
_PyModule_CreateInitialized
(
module
,
module_api_version
);
}
PyObject
*
_PyModule_CreateInitialized
(
struct
PyModuleDef
*
module
,
int
module_api_version
)
{
const
char
*
name
;
PyModuleObject
*
m
;
PyInterpreterState
*
interp
=
PyThreadState_Get
()
->
interp
;
if
(
interp
->
modules
==
NULL
)
Py_FatalError
(
"Python import machinery not initialized"
);
if
(
!
PyModuleDef_Init
(
module
))
return
NULL
;
name
=
module
->
m_name
;
...
...
Objects/typeobject.c
View file @
86b7afdf
...
...
@@ -3901,7 +3901,6 @@ import_copyreg(void)
{
PyObject
*
copyreg_str
;
PyObject
*
copyreg_module
;
PyInterpreterState
*
interp
=
PyThreadState_GET
()
->
interp
;
_Py_IDENTIFIER
(
copyreg
);
copyreg_str
=
_PyUnicode_FromId
(
&
PyId_copyreg
);
...
...
@@ -3913,7 +3912,7 @@ import_copyreg(void)
by storing a reference to the cached module in a static variable, but
this broke when multiple embedded interpreters were in use (see issue
#17408 and #19088). */
copyreg_module
=
PyDict_GetItemWithError
(
interp
->
modules
,
copyreg_str
);
copyreg_module
=
_PyImport_GetModuleWithError
(
copyreg_str
);
if
(
copyreg_module
!=
NULL
)
{
Py_INCREF
(
copyreg_module
);
return
copyreg_module
;
...
...
Python/_warnings.c
View file @
86b7afdf
...
...
@@ -44,7 +44,6 @@ static PyObject *
get_warnings_attr
(
const
char
*
attr
,
int
try_import
)
{
static
PyObject
*
warnings_str
=
NULL
;
PyObject
*
all_modules
;
PyObject
*
warnings_module
,
*
obj
;
if
(
warnings_str
==
NULL
)
{
...
...
@@ -64,9 +63,7 @@ get_warnings_attr(const char *attr, int try_import)
}
}
else
{
all_modules
=
PyImport_GetModuleDict
();
warnings_module
=
PyDict_GetItem
(
all_modules
,
warnings_str
);
warnings_module
=
_PyImport_GetModule
(
warnings_str
);
if
(
warnings_module
==
NULL
)
return
NULL
;
...
...
Python/bltinmodule.c
View file @
86b7afdf
...
...
@@ -2685,7 +2685,7 @@ _PyBuiltin_Init(void)
PyType_Ready
(
&
PyZip_Type
)
<
0
)
return
NULL
;
mod
=
PyModule_Create
(
&
builtinsmodule
);
mod
=
_PyModule_CreateInitialized
(
&
builtinsmodule
,
PYTHON_API_VERSION
);
if
(
mod
==
NULL
)
return
NULL
;
dict
=
PyModule_GetDict
(
mod
);
...
...
Python/ceval.c
View file @
86b7afdf
...
...
@@ -5054,7 +5054,7 @@ import_from(PyObject *v, PyObject *name)
Py_DECREF
(
pkgname
);
return
NULL
;
}
x
=
PyDict_GetItem
(
PyImport_GetModuleDict
(),
fullmodname
);
x
=
_PyImport_GetModule
(
fullmodname
);
Py_DECREF
(
fullmodname
);
if
(
x
==
NULL
)
{
goto
error
;
...
...
Python/import.c
View file @
86b7afdf
This diff is collapsed.
Click to expand it.
Python/importdl.c
View file @
86b7afdf
...
...
@@ -215,7 +215,8 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
else
Py_INCREF
(
path
);
if
(
_PyImport_FixupExtensionObject
(
m
,
name_unicode
,
path
)
<
0
)
PyObject
*
modules
=
PyImport_GetModuleDict
();
if
(
_PyImport_FixupExtensionObject
(
m
,
name_unicode
,
path
,
modules
)
<
0
)
goto
error
;
Py_DECREF
(
name_unicode
);
...
...
Python/pylifecycle.c
View file @
86b7afdf
...
...
@@ -41,6 +41,7 @@ _Py_IDENTIFIER(name);
_Py_IDENTIFIER
(
stdin
);
_Py_IDENTIFIER
(
stdout
);
_Py_IDENTIFIER
(
stderr
);
_Py_IDENTIFIER
(
threading
);
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -262,7 +263,6 @@ initimport(PyInterpreterState *interp, PyObject *sysmod)
{
PyObject
*
importlib
;
PyObject
*
impmod
;
PyObject
*
sys_modules
;
PyObject
*
value
;
/* Import _importlib through its frozen version, _frozen_importlib. */
...
...
@@ -293,11 +293,7 @@ initimport(PyInterpreterState *interp, PyObject *sysmod)
else
if
(
Py_VerboseFlag
)
{
PySys_FormatStderr
(
"import _imp # builtin
\n
"
);
}
sys_modules
=
PyImport_GetModuleDict
();
if
(
Py_VerboseFlag
)
{
PySys_FormatStderr
(
"import sys # builtin
\n
"
);
}
if
(
PyDict_SetItemString
(
sys_modules
,
"_imp"
,
impmod
)
<
0
)
{
if
(
_PyImport_SetModuleString
(
"_imp"
,
impmod
)
<
0
)
{
Py_FatalError
(
"Py_Initialize: can't save _imp to sys.modules"
);
}
...
...
@@ -647,10 +643,20 @@ void _Py_InitializeCore(const _PyCoreConfig *config)
if
(
!
_PyFloat_Init
())
Py_FatalError
(
"Py_InitializeCore: can't init float"
);
interp
->
modules
=
PyDict_New
();
if
(
interp
->
modules
==
NULL
)
PyObject
*
modules
=
PyDict_New
();
if
(
modules
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't make modules dictionary"
);
sysmod
=
_PySys_BeginInit
();
if
(
sysmod
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't initialize sys"
);
interp
->
sysdict
=
PyModule_GetDict
(
sysmod
);
if
(
interp
->
sysdict
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't initialize sys dict"
);
Py_INCREF
(
interp
->
sysdict
);
PyDict_SetItemString
(
interp
->
sysdict
,
"modules"
,
modules
);
_PyImport_FixupBuiltin
(
sysmod
,
"sys"
,
modules
);
/* Init Unicode implementation; relies on the codec registry */
if
(
_PyUnicode_Init
()
<
0
)
Py_FatalError
(
"Py_InitializeCore: can't initialize unicode"
);
...
...
@@ -661,7 +667,7 @@ void _Py_InitializeCore(const _PyCoreConfig *config)
bimod
=
_PyBuiltin_Init
();
if
(
bimod
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't initialize builtins modules"
);
_PyImport_FixupBuiltin
(
bimod
,
"builtins"
);
_PyImport_FixupBuiltin
(
bimod
,
"builtins"
,
modules
);
interp
->
builtins
=
PyModule_GetDict
(
bimod
);
if
(
interp
->
builtins
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't initialize builtins dict"
);
...
...
@@ -670,17 +676,6 @@ void _Py_InitializeCore(const _PyCoreConfig *config)
/* initialize builtin exceptions */
_PyExc_Init
(
bimod
);
sysmod
=
_PySys_BeginInit
();
if
(
sysmod
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't initialize sys"
);
interp
->
sysdict
=
PyModule_GetDict
(
sysmod
);
if
(
interp
->
sysdict
==
NULL
)
Py_FatalError
(
"Py_InitializeCore: can't initialize sys dict"
);
Py_INCREF
(
interp
->
sysdict
);
_PyImport_FixupBuiltin
(
sysmod
,
"sys"
);
PyDict_SetItemString
(
interp
->
sysdict
,
"modules"
,
interp
->
modules
);
/* Set up a preliminary stderr printer until we have enough
infrastructure for the io module in place. */
pstderr
=
PyFile_NewStdPrinter
(
fileno
(
stderr
));
...
...
@@ -1178,9 +1173,22 @@ Py_NewInterpreter(void)
/* XXX The following is lax in error checking */
interp
->
modules
=
PyDict_New
();
PyObject
*
modules
=
PyDict_New
();
if
(
modules
==
NULL
)
Py_FatalError
(
"Py_NewInterpreter: can't make modules dictionary"
);
bimod
=
_PyImport_FindBuiltin
(
"builtins"
);
sysmod
=
_PyImport_FindBuiltin
(
"sys"
,
modules
);
if
(
sysmod
!=
NULL
)
{
interp
->
sysdict
=
PyModule_GetDict
(
sysmod
);
if
(
interp
->
sysdict
==
NULL
)
goto
handle_error
;
Py_INCREF
(
interp
->
sysdict
);
PyDict_SetItemString
(
interp
->
sysdict
,
"modules"
,
modules
);
PySys_SetPath
(
Py_GetPath
());
_PySys_EndInit
(
interp
->
sysdict
);
}
bimod
=
_PyImport_FindBuiltin
(
"builtins"
,
modules
);
if
(
bimod
!=
NULL
)
{
interp
->
builtins
=
PyModule_GetDict
(
bimod
);
if
(
interp
->
builtins
==
NULL
)
...
...
@@ -1191,18 +1199,9 @@ Py_NewInterpreter(void)
/* initialize builtin exceptions */
_PyExc_Init
(
bimod
);
sysmod
=
_PyImport_FindBuiltin
(
"sys"
);
if
(
bimod
!=
NULL
&&
sysmod
!=
NULL
)
{
PyObject
*
pstderr
;
interp
->
sysdict
=
PyModule_GetDict
(
sysmod
);
if
(
interp
->
sysdict
==
NULL
)
goto
handle_error
;
Py_INCREF
(
interp
->
sysdict
);
_PySys_EndInit
(
interp
->
sysdict
);
PySys_SetPath
(
Py_GetPath
());
PyDict_SetItemString
(
interp
->
sysdict
,
"modules"
,
interp
->
modules
);
/* Set up a preliminary stderr printer until we have enough
infrastructure for the io module in place. */
pstderr
=
PyFile_NewStdPrinter
(
fileno
(
stderr
));
...
...
@@ -1882,14 +1881,13 @@ wait_for_thread_shutdown(void)
#ifdef WITH_THREAD
_Py_IDENTIFIER
(
_shutdown
);
PyObject
*
result
;
PyThreadState
*
tstate
=
PyThreadState_GET
();
PyObject
*
threading
=
PyMapping_GetItemString
(
tstate
->
interp
->
modules
,
"threading"
);
PyObject
*
threading
=
_PyImport_GetModuleId
(
&
PyId_threading
);
if
(
threading
==
NULL
)
{
/* threading not imported */
PyErr_Clear
();
return
;
}
Py_INCREF
(
threading
);
result
=
_PyObject_CallMethodId
(
threading
,
&
PyId__shutdown
,
NULL
);
if
(
result
==
NULL
)
{
PyErr_WriteUnraisable
(
threading
);
...
...
Python/pystate.c
View file @
86b7afdf
...
...
@@ -97,7 +97,6 @@ PyInterpreterState_New(void)
if
(
head_mutex
==
NULL
)
Py_FatalError
(
"Can't initialize threads for interpreter"
);
#endif
interp
->
modules
=
NULL
;
interp
->
modules_by_index
=
NULL
;
interp
->
sysdict
=
NULL
;
interp
->
builtins
=
NULL
;
...
...
@@ -158,7 +157,6 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
Py_CLEAR
(
interp
->
codec_search_path
);
Py_CLEAR
(
interp
->
codec_search_cache
);
Py_CLEAR
(
interp
->
codec_error_registry
);
Py_CLEAR
(
interp
->
modules
);
Py_CLEAR
(
interp
->
modules_by_index
);
Py_CLEAR
(
interp
->
sysdict
);
Py_CLEAR
(
interp
->
builtins
);
...
...
Python/sysmodule.c
View file @
86b7afdf
...
...
@@ -159,13 +159,11 @@ static PyObject *
sys_displayhook
(
PyObject
*
self
,
PyObject
*
o
)
{
PyObject
*
outf
;
PyInterpreterState
*
interp
=
PyThreadState_GET
()
->
interp
;
PyObject
*
modules
=
interp
->
modules
;
PyObject
*
builtins
;
static
PyObject
*
newline
=
NULL
;
int
err
;
builtins
=
_Py
Dict_GetItemId
(
modules
,
&
PyId_builtins
);
builtins
=
_Py
Import_GetModuleId
(
&
PyId_builtins
);
if
(
builtins
==
NULL
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"lost builtins module"
);
return
NULL
;
...
...
@@ -1929,7 +1927,7 @@ _PySys_BeginInit(void)
PyObject
*
m
,
*
sysdict
,
*
version_info
;
int
res
;
m
=
PyModule_Create
(
&
sysmodule
);
m
=
_PyModule_CreateInitialized
(
&
sysmodule
,
PYTHON_API_VERSION
);
if
(
m
==
NULL
)
return
NULL
;
sysdict
=
PyModule_GetDict
(
m
);
...
...
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