From 114da4ecd3ab8267b8adf3041de3b853610c0e22 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 13 Dec 2018 19:14:14 +0900 Subject: [PATCH 1/3] test --- MySQLdb/_mysql.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index b0ba5310..891bd1e5 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -2635,10 +2635,6 @@ init_mysql(void) { PyObject *dict, *module, *emod, *edict; -#ifndef IS_PY3K - _mysql_ConnectionObject_Type.ob_type = &PyType_Type; - _mysql_ResultObject_Type.ob_type = &PyType_Type; -#endif _mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc; _mysql_ConnectionObject_Type.tp_new = PyType_GenericNew; _mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc; @@ -2652,8 +2648,10 @@ init_mysql(void) module = PyModule_Create(&_mysqlmodule); if (!module) return module; /* this really should never happen */ #else - _mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del; - _mysql_ResultObject_Type.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0) + return; + if (PyType_Ready(&_mysql_ResultObject_Type) < 0) + return; module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__, (PyObject *)NULL, PYTHON_API_VERSION); if (!module) return; /* this really should never happen */ From eeef0799ad691da7420f9a3844b7a810c85bed1e Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 13 Dec 2018 19:56:40 +0900 Subject: [PATCH 2/3] test2 --- MySQLdb/_mysql.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index 891bd1e5..b70c904e 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -2635,9 +2635,7 @@ init_mysql(void) { PyObject *dict, *module, *emod, *edict; - _mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc; _mysql_ConnectionObject_Type.tp_new = PyType_GenericNew; - _mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc; _mysql_ResultObject_Type.tp_new = PyType_GenericNew; #ifdef IS_PY3K if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0) From 02dd6f8e6946107821bbcbcb18bec2b509ef4422 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 13 Dec 2018 20:00:28 +0900 Subject: [PATCH 3/3] test3 --- MySQLdb/_mysql.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index b70c904e..1f1b299e 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -2468,7 +2468,7 @@ PyTypeObject _mysql_ConnectionObject_Type = { 0, /* (long) tp_dictoffset */ (initproc)_mysql_ConnectionObject_Initialize, /* tp_init */ NULL, /* tp_alloc */ - NULL, /* tp_new */ + PyType_GenericNew, /* tp_new */ NULL, /* tp_free Low-level free-memory routine */ 0, /* (PyObject *) tp_bases */ 0, /* (PyObject *) tp_mro method resolution order */ @@ -2536,7 +2536,7 @@ PyTypeObject _mysql_ResultObject_Type = { 0, /* (long) tp_dictoffset */ (initproc)_mysql_ResultObject_Initialize, /* tp_init */ NULL, /* tp_alloc */ - NULL, /* tp_new */ + PyType_GenericNew, /* tp_new */ NULL, /* tp_free Low-level free-memory routine */ 0, /* (PyObject *) tp_bases */ 0, /* (PyObject *) tp_mro method resolution order */ @@ -2635,8 +2635,6 @@ init_mysql(void) { PyObject *dict, *module, *emod, *edict; - _mysql_ConnectionObject_Type.tp_new = PyType_GenericNew; - _mysql_ResultObject_Type.tp_new = PyType_GenericNew; #ifdef IS_PY3K if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0) return NULL;