From e65392e0d87c601822c51c50c803eab58f1508d3 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 20 Mar 2013 22:27:10 +0000 Subject: [PATCH] PyType_GenericAlloc is the default allocator: no need to specify --- psycopg/adapter_asis.c | 2 +- psycopg/adapter_binary.c | 2 +- psycopg/adapter_datetime.c | 2 +- psycopg/adapter_list.c | 2 +- psycopg/adapter_pboolean.c | 2 +- psycopg/adapter_pdecimal.c | 2 +- psycopg/adapter_pfloat.c | 2 +- psycopg/adapter_pint.c | 2 +- psycopg/adapter_qstring.c | 2 +- psycopg/connection_type.c | 2 +- psycopg/cursor_type.c | 2 +- psycopg/diagnostics_type.c | 2 +- psycopg/error_type.c | 2 +- psycopg/lobject_type.c | 2 +- psycopg/microprotocols_proto.c | 2 +- psycopg/notify_type.c | 2 +- psycopg/psycopgmodule.c | 79 +++++++++++++++------------------- psycopg/typecast.c | 8 ++-- psycopg/xid_type.c | 2 +- 19 files changed, 55 insertions(+), 66 deletions(-) diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c index 7952bbae..7f5d3850 100644 --- a/psycopg/adapter_asis.c +++ b/psycopg/adapter_asis.c @@ -204,7 +204,7 @@ PyTypeObject asisType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ asis_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ asis_new, /*tp_new*/ }; diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index 058c9b9b..08f41b84 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -313,7 +313,7 @@ PyTypeObject binaryType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ binary_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ binary_new, /*tp_new*/ }; diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index 0fa10092..9713a5a5 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -271,7 +271,7 @@ PyTypeObject pydatetimeType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ pydatetime_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ pydatetime_new, /*tp_new*/ }; diff --git a/psycopg/adapter_list.c b/psycopg/adapter_list.c index 5e25234b..6650dd96 100644 --- a/psycopg/adapter_list.c +++ b/psycopg/adapter_list.c @@ -268,7 +268,7 @@ PyTypeObject listType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ list_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ list_new, /*tp_new*/ }; diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c index 75b0723d..879e233d 100644 --- a/psycopg/adapter_pboolean.c +++ b/psycopg/adapter_pboolean.c @@ -204,7 +204,7 @@ PyTypeObject pbooleanType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ pboolean_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ pboolean_new, /*tp_new*/ }; diff --git a/psycopg/adapter_pdecimal.c b/psycopg/adapter_pdecimal.c index 1e3b6f97..09748514 100644 --- a/psycopg/adapter_pdecimal.c +++ b/psycopg/adapter_pdecimal.c @@ -260,7 +260,7 @@ PyTypeObject pdecimalType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ pdecimal_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ pdecimal_new, /*tp_new*/ }; diff --git a/psycopg/adapter_pfloat.c b/psycopg/adapter_pfloat.c index 8871c54b..abdc8a4c 100644 --- a/psycopg/adapter_pfloat.c +++ b/psycopg/adapter_pfloat.c @@ -233,7 +233,7 @@ PyTypeObject pfloatType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ pfloat_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ pfloat_new, /*tp_new*/ }; diff --git a/psycopg/adapter_pint.c b/psycopg/adapter_pint.c index b8383d71..ece7a9ca 100644 --- a/psycopg/adapter_pint.c +++ b/psycopg/adapter_pint.c @@ -219,7 +219,7 @@ PyTypeObject pintType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ pint_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ pint_new, /*tp_new*/ }; diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 04bde73c..f2efac34 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -296,7 +296,7 @@ PyTypeObject qstringType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ qstring_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ qstring_new, /*tp_new*/ }; diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index af8905d5..1192a4ac 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -1243,6 +1243,6 @@ PyTypeObject connectionType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ connection_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ connection_new, /*tp_new*/ }; diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index dd1780d7..8794e7fe 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -2002,6 +2002,6 @@ PyTypeObject cursorType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ cursor_init, /*tp_init*/ - 0, /*tp_alloc Will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ cursor_new, /*tp_new*/ }; diff --git a/psycopg/diagnostics_type.c b/psycopg/diagnostics_type.c index 36354ff5..77019bfb 100644 --- a/psycopg/diagnostics_type.c +++ b/psycopg/diagnostics_type.c @@ -200,6 +200,6 @@ PyTypeObject diagnosticsType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ (initproc)diagnostics_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ diagnostics_new, /*tp_new*/ }; diff --git a/psycopg/error_type.c b/psycopg/error_type.c index da3056b7..fd0947bc 100644 --- a/psycopg/error_type.c +++ b/psycopg/error_type.c @@ -282,6 +282,6 @@ PyTypeObject errorType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ (initproc)error_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ error_new, /*tp_new*/ }; diff --git a/psycopg/lobject_type.c b/psycopg/lobject_type.c index 6f6ac335..90546e79 100644 --- a/psycopg/lobject_type.c +++ b/psycopg/lobject_type.c @@ -441,7 +441,7 @@ PyTypeObject lobjectType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ lobject_init, /*tp_init*/ - 0, /*tp_alloc Will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ lobject_new, /*tp_new*/ }; diff --git a/psycopg/microprotocols_proto.c b/psycopg/microprotocols_proto.c index c0afc23d..6065efdf 100644 --- a/psycopg/microprotocols_proto.c +++ b/psycopg/microprotocols_proto.c @@ -179,6 +179,6 @@ PyTypeObject isqlquoteType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ isqlquote_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ isqlquote_new, /*tp_new*/ }; diff --git a/psycopg/notify_type.c b/psycopg/notify_type.c index 17620c4d..973ee169 100644 --- a/psycopg/notify_type.c +++ b/psycopg/notify_type.c @@ -303,7 +303,7 @@ PyTypeObject notifyType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ (initproc)notify_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ notify_new, /*tp_new*/ }; diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 36984e59..4f61d765 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -768,44 +768,59 @@ INIT_MODULE(_psycopg)(void) /* initialize all the new types and then the module */ Py_TYPE(&connectionType) = &PyType_Type; - Py_TYPE(&cursorType) = &PyType_Type; - Py_TYPE(&typecastType) = &PyType_Type; - Py_TYPE(&qstringType) = &PyType_Type; - Py_TYPE(&binaryType) = &PyType_Type; - Py_TYPE(&isqlquoteType) = &PyType_Type; - Py_TYPE(&pbooleanType) = &PyType_Type; - Py_TYPE(&pintType) = &PyType_Type; - Py_TYPE(&pfloatType) = &PyType_Type; - Py_TYPE(&pdecimalType) = &PyType_Type; - Py_TYPE(&asisType) = &PyType_Type; - Py_TYPE(&listType) = &PyType_Type; - Py_TYPE(&chunkType) = &PyType_Type; - Py_TYPE(¬ifyType) = &PyType_Type; - Py_TYPE(&xidType) = &PyType_Type; - Py_TYPE(&errorType) = &PyType_Type; - Py_TYPE(&diagnosticsType) = &PyType_Type; - if (PyType_Ready(&connectionType) == -1) goto exit; + + Py_TYPE(&cursorType) = &PyType_Type; if (PyType_Ready(&cursorType) == -1) goto exit; + + Py_TYPE(&typecastType) = &PyType_Type; if (PyType_Ready(&typecastType) == -1) goto exit; + + Py_TYPE(&qstringType) = &PyType_Type; if (PyType_Ready(&qstringType) == -1) goto exit; + + Py_TYPE(&binaryType) = &PyType_Type; if (PyType_Ready(&binaryType) == -1) goto exit; + + Py_TYPE(&isqlquoteType) = &PyType_Type; if (PyType_Ready(&isqlquoteType) == -1) goto exit; + + Py_TYPE(&pbooleanType) = &PyType_Type; if (PyType_Ready(&pbooleanType) == -1) goto exit; + + Py_TYPE(&pintType) = &PyType_Type; if (PyType_Ready(&pintType) == -1) goto exit; + + Py_TYPE(&pfloatType) = &PyType_Type; if (PyType_Ready(&pfloatType) == -1) goto exit; + + Py_TYPE(&pdecimalType) = &PyType_Type; if (PyType_Ready(&pdecimalType) == -1) goto exit; + + Py_TYPE(&asisType) = &PyType_Type; if (PyType_Ready(&asisType) == -1) goto exit; + + Py_TYPE(&listType) = &PyType_Type; if (PyType_Ready(&listType) == -1) goto exit; + + Py_TYPE(&chunkType) = &PyType_Type; if (PyType_Ready(&chunkType) == -1) goto exit; + + Py_TYPE(¬ifyType) = &PyType_Type; if (PyType_Ready(¬ifyType) == -1) goto exit; + + Py_TYPE(&xidType) = &PyType_Type; if (PyType_Ready(&xidType) == -1) goto exit; + + Py_TYPE(&errorType) = &PyType_Type; errorType.tp_base = (PyTypeObject *)PyExc_StandardError; if (PyType_Ready(&errorType) == -1) goto exit; + + Py_TYPE(&diagnosticsType) = &PyType_Type; if (PyType_Ready(&diagnosticsType) == -1) goto exit; #ifdef PSYCOPG_EXTENSIONS - Py_TYPE(&lobjectType) = &PyType_Type; + Py_TYPE(&lobjectType) = &PyType_Type; if (PyType_Ready(&lobjectType) == -1) goto exit; #endif @@ -813,6 +828,7 @@ INIT_MODULE(_psycopg)(void) #ifdef HAVE_MXDATETIME Py_TYPE(&mxdatetimeType) = &PyType_Type; if (PyType_Ready(&mxdatetimeType) == -1) goto exit; + if (0 != mxDateTime_ImportModuleAndAPI()) { PyErr_Clear(); @@ -921,33 +937,6 @@ INIT_MODULE(_psycopg)(void) if (0 != psyco_errors_init()) { goto exit; } psyco_errors_fill(dict); - /* Solve win32 build issue about non-constant initializer element */ - cursorType.tp_alloc = PyType_GenericAlloc; - binaryType.tp_alloc = PyType_GenericAlloc; - isqlquoteType.tp_alloc = PyType_GenericAlloc; - pbooleanType.tp_alloc = PyType_GenericAlloc; - pintType.tp_alloc = PyType_GenericAlloc; - pfloatType.tp_alloc = PyType_GenericAlloc; - pdecimalType.tp_alloc = PyType_GenericAlloc; - connectionType.tp_alloc = PyType_GenericAlloc; - asisType.tp_alloc = PyType_GenericAlloc; - qstringType.tp_alloc = PyType_GenericAlloc; - listType.tp_alloc = PyType_GenericAlloc; - chunkType.tp_alloc = PyType_GenericAlloc; - pydatetimeType.tp_alloc = PyType_GenericAlloc; - notifyType.tp_alloc = PyType_GenericAlloc; - xidType.tp_alloc = PyType_GenericAlloc; - errorType.tp_alloc = PyType_GenericAlloc; - diagnosticsType.tp_alloc = PyType_GenericAlloc; - -#ifdef PSYCOPG_EXTENSIONS - lobjectType.tp_alloc = PyType_GenericAlloc; -#endif - -#ifdef HAVE_MXDATETIME - mxdatetimeType.tp_alloc = PyType_GenericAlloc; -#endif - Dprintf("initpsycopg: module initialization complete"); exit: diff --git a/psycopg/typecast.c b/psycopg/typecast.c index 74506906..048f44a6 100644 --- a/psycopg/typecast.c +++ b/psycopg/typecast.c @@ -508,7 +508,7 @@ PyTypeObject typecastType = { 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - 0, /*tp_methods*/ + 0, /*tp_methods*/ typecastObject_members, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -516,9 +516,9 @@ PyTypeObject typecastType = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ - 0, /*tp_new*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ }; static PyObject * diff --git a/psycopg/xid_type.c b/psycopg/xid_type.c index bd4f0e4c..67ea0112 100644 --- a/psycopg/xid_type.c +++ b/psycopg/xid_type.c @@ -312,7 +312,7 @@ PyTypeObject xidType = { 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ (initproc)xid_init, /*tp_init*/ - 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ + 0, /*tp_alloc*/ xid_new, /*tp_new*/ };