mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Initialize the ob_type field of PyAST_Type dynamically (in
initparser()) instead of statically (in the initializer). The static initialization, using the address of an object in a different DLL, is too much for the Microsoft VC++ compiler, and we want to be able to build this module as a separate DLL (it's nice to have but we don't want to increase the core DLL's size by 25K). This same trick has been applied to a number of modules, e.g. NumPy and _tkinter.
This commit is contained in:
parent
ca756f2a1d
commit
f2b2dac5eb
1 changed files with 7 additions and 3 deletions
|
@ -197,7 +197,7 @@ staticforward int parser_compare Py_PROTO((PyAST_Object *left,
|
||||||
/* static */
|
/* static */
|
||||||
PyTypeObject PyAST_Type = {
|
PyTypeObject PyAST_Type = {
|
||||||
|
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
PyObject_HEAD_INIT(NULL)
|
||||||
0,
|
0,
|
||||||
"ast", /* tp_name */
|
"ast", /* tp_name */
|
||||||
sizeof(PyAST_Object), /* tp_basicsize */
|
sizeof(PyAST_Object), /* tp_basicsize */
|
||||||
|
@ -2593,8 +2593,12 @@ static PyMethodDef parser_functions[] = {
|
||||||
void
|
void
|
||||||
initparser()
|
initparser()
|
||||||
{
|
{
|
||||||
PyObject* module = Py_InitModule("parser", parser_functions);
|
PyObject* module;
|
||||||
PyObject* dict = PyModule_GetDict(module);
|
PyObject* dict;
|
||||||
|
|
||||||
|
PyAST_Type.ob_type = &PyType_Type;
|
||||||
|
module = Py_InitModule("parser", parser_functions);
|
||||||
|
dict = PyModule_GetDict(module);
|
||||||
|
|
||||||
parser_error = PyString_FromString("parser.ParserError");
|
parser_error = PyString_FromString("parser.ParserError");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue