@@ -2468,7 +2468,7 @@ PyTypeObject _mysql_ConnectionObject_Type = {
2468
2468
0 , /* (long) tp_dictoffset */
2469
2469
(initproc )_mysql_ConnectionObject_Initialize , /* tp_init */
2470
2470
NULL , /* tp_alloc */
2471
- NULL , /* tp_new */
2471
+ PyType_GenericNew , /* tp_new */
2472
2472
NULL , /* tp_free Low-level free-memory routine */
2473
2473
0 , /* (PyObject *) tp_bases */
2474
2474
0 , /* (PyObject *) tp_mro method resolution order */
@@ -2536,7 +2536,7 @@ PyTypeObject _mysql_ResultObject_Type = {
2536
2536
0 , /* (long) tp_dictoffset */
2537
2537
(initproc )_mysql_ResultObject_Initialize , /* tp_init */
2538
2538
NULL , /* tp_alloc */
2539
- NULL , /* tp_new */
2539
+ PyType_GenericNew , /* tp_new */
2540
2540
NULL , /* tp_free Low-level free-memory routine */
2541
2541
0 , /* (PyObject *) tp_bases */
2542
2542
0 , /* (PyObject *) tp_mro method resolution order */
@@ -2635,14 +2635,6 @@ init_mysql(void)
2635
2635
{
2636
2636
PyObject * dict , * module , * emod , * edict ;
2637
2637
2638
- #ifndef IS_PY3K
2639
- _mysql_ConnectionObject_Type .ob_type = & PyType_Type ;
2640
- _mysql_ResultObject_Type .ob_type = & PyType_Type ;
2641
- #endif
2642
- _mysql_ConnectionObject_Type .tp_alloc = PyType_GenericAlloc ;
2643
- _mysql_ConnectionObject_Type .tp_new = PyType_GenericNew ;
2644
- _mysql_ResultObject_Type .tp_alloc = PyType_GenericAlloc ;
2645
- _mysql_ResultObject_Type .tp_new = PyType_GenericNew ;
2646
2638
#ifdef IS_PY3K
2647
2639
if (PyType_Ready (& _mysql_ConnectionObject_Type ) < 0 )
2648
2640
return NULL ;
@@ -2652,8 +2644,10 @@ init_mysql(void)
2652
2644
module = PyModule_Create (& _mysqlmodule );
2653
2645
if (!module ) return module ; /* this really should never happen */
2654
2646
#else
2655
- _mysql_ConnectionObject_Type .tp_free = _PyObject_GC_Del ;
2656
- _mysql_ResultObject_Type .tp_free = _PyObject_GC_Del ;
2647
+ if (PyType_Ready (& _mysql_ConnectionObject_Type ) < 0 )
2648
+ return ;
2649
+ if (PyType_Ready (& _mysql_ResultObject_Type ) < 0 )
2650
+ return ;
2657
2651
module = Py_InitModule4 ("_mysql" , _mysql_methods , _mysql___doc__ ,
2658
2652
(PyObject * )NULL , PYTHON_API_VERSION );
2659
2653
if (!module ) return ; /* this really should never happen */
0 commit comments