mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 02:54:29 +08:00
Refactor extension module initialization (#313)
This commit is contained in:
@ -2468,7 +2468,7 @@ PyTypeObject _mysql_ConnectionObject_Type = {
|
|||||||
0, /* (long) tp_dictoffset */
|
0, /* (long) tp_dictoffset */
|
||||||
(initproc)_mysql_ConnectionObject_Initialize, /* tp_init */
|
(initproc)_mysql_ConnectionObject_Initialize, /* tp_init */
|
||||||
NULL, /* tp_alloc */
|
NULL, /* tp_alloc */
|
||||||
NULL, /* tp_new */
|
PyType_GenericNew, /* tp_new */
|
||||||
NULL, /* tp_free Low-level free-memory routine */
|
NULL, /* tp_free Low-level free-memory routine */
|
||||||
0, /* (PyObject *) tp_bases */
|
0, /* (PyObject *) tp_bases */
|
||||||
0, /* (PyObject *) tp_mro method resolution order */
|
0, /* (PyObject *) tp_mro method resolution order */
|
||||||
@ -2536,7 +2536,7 @@ PyTypeObject _mysql_ResultObject_Type = {
|
|||||||
0, /* (long) tp_dictoffset */
|
0, /* (long) tp_dictoffset */
|
||||||
(initproc)_mysql_ResultObject_Initialize, /* tp_init */
|
(initproc)_mysql_ResultObject_Initialize, /* tp_init */
|
||||||
NULL, /* tp_alloc */
|
NULL, /* tp_alloc */
|
||||||
NULL, /* tp_new */
|
PyType_GenericNew, /* tp_new */
|
||||||
NULL, /* tp_free Low-level free-memory routine */
|
NULL, /* tp_free Low-level free-memory routine */
|
||||||
0, /* (PyObject *) tp_bases */
|
0, /* (PyObject *) tp_bases */
|
||||||
0, /* (PyObject *) tp_mro method resolution order */
|
0, /* (PyObject *) tp_mro method resolution order */
|
||||||
@ -2635,14 +2635,6 @@ init_mysql(void)
|
|||||||
{
|
{
|
||||||
PyObject *dict, *module, *emod, *edict;
|
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;
|
|
||||||
_mysql_ResultObject_Type.tp_new = PyType_GenericNew;
|
|
||||||
#ifdef IS_PY3K
|
#ifdef IS_PY3K
|
||||||
if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0)
|
if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2652,8 +2644,10 @@ init_mysql(void)
|
|||||||
module = PyModule_Create(&_mysqlmodule);
|
module = PyModule_Create(&_mysqlmodule);
|
||||||
if (!module) return module; /* this really should never happen */
|
if (!module) return module; /* this really should never happen */
|
||||||
#else
|
#else
|
||||||
_mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del;
|
if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0)
|
||||||
_mysql_ResultObject_Type.tp_free = _PyObject_GC_Del;
|
return;
|
||||||
|
if (PyType_Ready(&_mysql_ResultObject_Type) < 0)
|
||||||
|
return;
|
||||||
module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__,
|
module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__,
|
||||||
(PyObject *)NULL, PYTHON_API_VERSION);
|
(PyObject *)NULL, PYTHON_API_VERSION);
|
||||||
if (!module) return; /* this really should never happen */
|
if (!module) return; /* this really should never happen */
|
||||||
|
Reference in New Issue
Block a user