From a2b01cdf4221f4fad94143606c06141ce91ef7bd Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 15 Aug 2014 02:37:37 +0100 Subject: [PATCH] Dropped simple type wrapper functions These functions don't need to exist: exposing the type in the module is enough. It is actually better as one may use isinstance and such. --- psycopg/adapter_asis.c | 14 -------------- psycopg/adapter_asis.h | 6 ------ psycopg/adapter_binary.c | 14 -------------- psycopg/adapter_binary.h | 7 ------- psycopg/adapter_list.c | 14 -------------- psycopg/adapter_list.h | 4 ---- psycopg/adapter_pboolean.c | 14 -------------- psycopg/adapter_pboolean.h | 6 ------ psycopg/adapter_pdecimal.c | 14 -------------- psycopg/adapter_pdecimal.h | 6 ------ psycopg/adapter_pfloat.c | 14 -------------- psycopg/adapter_pfloat.h | 6 ------ psycopg/adapter_pint.c | 14 -------------- psycopg/adapter_pint.h | 6 ------ psycopg/adapter_qstring.c | 14 -------------- psycopg/adapter_qstring.h | 6 ------ psycopg/psycopgmodule.c | 24 ++++++++---------------- 17 files changed, 8 insertions(+), 175 deletions(-) diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c index 72768ac7..d64b1410 100644 --- a/psycopg/adapter_asis.c +++ b/psycopg/adapter_asis.c @@ -194,17 +194,3 @@ PyTypeObject asisType = { 0, /*tp_alloc*/ asis_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_AsIs(PyObject *module, PyObject *args) -{ - PyObject *obj; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&asisType, obj, NULL); -} diff --git a/psycopg/adapter_asis.h b/psycopg/adapter_asis.h index 04ba08bc..0e1caaee 100644 --- a/psycopg/adapter_asis.h +++ b/psycopg/adapter_asis.h @@ -40,12 +40,6 @@ typedef struct { } asisObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_AsIs(PyObject *module, PyObject *args); -#define psyco_AsIs_doc \ - "AsIs(obj) -> new AsIs wrapper object" - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index 1bf04aa4..485dc5a4 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -299,17 +299,3 @@ PyTypeObject binaryType = { 0, /*tp_alloc*/ binary_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_Binary(PyObject *module, PyObject *args) -{ - PyObject *str; - - if (!PyArg_ParseTuple(args, "O", &str)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&binaryType, str, NULL); -} diff --git a/psycopg/adapter_binary.h b/psycopg/adapter_binary.h index 408efc77..1c12b070 100644 --- a/psycopg/adapter_binary.h +++ b/psycopg/adapter_binary.h @@ -40,13 +40,6 @@ typedef struct { PyObject *conn; } binaryObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_Binary(PyObject *module, PyObject *args); -#define psyco_Binary_doc \ - "Binary(buffer) -> new binary object\n\n" \ - "Build an object capable to hold a binary string value." - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_list.c b/psycopg/adapter_list.c index 6335f64b..e68b1978 100644 --- a/psycopg/adapter_list.c +++ b/psycopg/adapter_list.c @@ -260,17 +260,3 @@ PyTypeObject listType = { 0, /*tp_alloc*/ list_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_List(PyObject *module, PyObject *args) -{ - PyObject *obj; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&listType, obj, NULL); -} diff --git a/psycopg/adapter_list.h b/psycopg/adapter_list.h index 8ec20f68..e5bf77ee 100644 --- a/psycopg/adapter_list.h +++ b/psycopg/adapter_list.h @@ -39,10 +39,6 @@ typedef struct { PyObject *connection; } listObject; -HIDDEN PyObject *psyco_List(PyObject *module, PyObject *args); -#define psyco_List_doc \ - "List(list, enc) -> new quoted list" - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c index e48f5eb6..8a5950d8 100644 --- a/psycopg/adapter_pboolean.c +++ b/psycopg/adapter_pboolean.c @@ -191,17 +191,3 @@ PyTypeObject pbooleanType = { 0, /*tp_alloc*/ pboolean_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_Boolean(PyObject *module, PyObject *args) -{ - PyObject *obj; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&pbooleanType, obj, NULL); -} diff --git a/psycopg/adapter_pboolean.h b/psycopg/adapter_pboolean.h index b1bb18ae..bd642bf5 100644 --- a/psycopg/adapter_pboolean.h +++ b/psycopg/adapter_pboolean.h @@ -40,12 +40,6 @@ typedef struct { } pbooleanObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_Boolean(PyObject *module, PyObject *args); -#define psyco_Boolean_doc \ - "Boolean(obj) -> new boolean value" - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_pdecimal.c b/psycopg/adapter_pdecimal.c index 0ec4826c..fcff9d20 100644 --- a/psycopg/adapter_pdecimal.c +++ b/psycopg/adapter_pdecimal.c @@ -247,17 +247,3 @@ PyTypeObject pdecimalType = { 0, /*tp_alloc*/ pdecimal_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_Decimal(PyObject *module, PyObject *args) -{ - PyObject *obj; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&pdecimalType, obj, NULL); -} diff --git a/psycopg/adapter_pdecimal.h b/psycopg/adapter_pdecimal.h index 4f89fad5..4a38e299 100644 --- a/psycopg/adapter_pdecimal.h +++ b/psycopg/adapter_pdecimal.h @@ -40,12 +40,6 @@ typedef struct { } pdecimalObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_Decimal(PyObject *module, PyObject *args); -#define psyco_Decimal_doc \ - "Decimal(obj) -> new decimal.Decimal value" - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_pfloat.c b/psycopg/adapter_pfloat.c index 5343f746..c33ccae7 100644 --- a/psycopg/adapter_pfloat.c +++ b/psycopg/adapter_pfloat.c @@ -220,17 +220,3 @@ PyTypeObject pfloatType = { 0, /*tp_alloc*/ pfloat_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_Float(PyObject *module, PyObject *args) -{ - PyObject *obj; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&pfloatType, obj, NULL); -} diff --git a/psycopg/adapter_pfloat.h b/psycopg/adapter_pfloat.h index 7439c04f..2c0af473 100644 --- a/psycopg/adapter_pfloat.h +++ b/psycopg/adapter_pfloat.h @@ -40,12 +40,6 @@ typedef struct { } pfloatObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_Float(PyObject *module, PyObject *args); -#define psyco_Float_doc \ - "Float(obj) -> new float value" - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_pint.c b/psycopg/adapter_pint.c index 977932bc..18c74b28 100644 --- a/psycopg/adapter_pint.c +++ b/psycopg/adapter_pint.c @@ -206,17 +206,3 @@ PyTypeObject pintType = { 0, /*tp_alloc*/ pint_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_Int(PyObject *module, PyObject *args) -{ - PyObject *obj; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&pintType, obj, NULL); -} diff --git a/psycopg/adapter_pint.h b/psycopg/adapter_pint.h index fd553e8b..5488d24f 100644 --- a/psycopg/adapter_pint.h +++ b/psycopg/adapter_pint.h @@ -40,12 +40,6 @@ typedef struct { } pintObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_Int(PyObject *module, PyObject *args); -#define psyco_Int_doc \ - "Int(obj) -> new int value" - #ifdef __cplusplus } #endif diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 36b0a959..2e3ab0ae 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -287,17 +287,3 @@ PyTypeObject qstringType = { 0, /*tp_alloc*/ qstring_new, /*tp_new*/ }; - - -/** module-level functions **/ - -PyObject * -psyco_QuotedString(PyObject *module, PyObject *args) -{ - PyObject *str; - - if (!PyArg_ParseTuple(args, "O", &str)) - return NULL; - - return PyObject_CallFunctionObjArgs((PyObject *)&qstringType, str, NULL); -} diff --git a/psycopg/adapter_qstring.h b/psycopg/adapter_qstring.h index 0446f276..b7b086f3 100644 --- a/psycopg/adapter_qstring.h +++ b/psycopg/adapter_qstring.h @@ -41,12 +41,6 @@ typedef struct { connectionObject *conn; } qstringObject; -/* functions exported to psycopgmodule.c */ - -HIDDEN PyObject *psyco_QuotedString(PyObject *module, PyObject *args); -#define psyco_QuotedString_doc \ - "QuotedString(str, enc) -> new quoted string" - #ifdef __cplusplus } #endif diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 98cc995b..04c0ed7c 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -678,20 +678,6 @@ static PyMethodDef psycopgMethods[] = { {"new_array_type", (PyCFunction)typecast_array_from_python, METH_VARARGS|METH_KEYWORDS, typecast_array_from_python_doc}, - {"AsIs", (PyCFunction)psyco_AsIs, - METH_VARARGS, psyco_AsIs_doc}, - {"QuotedString", (PyCFunction)psyco_QuotedString, - METH_VARARGS, psyco_QuotedString_doc}, - {"Boolean", (PyCFunction)psyco_Boolean, - METH_VARARGS, psyco_Boolean_doc}, - {"Int", (PyCFunction)psyco_Int, - METH_VARARGS, psyco_Int_doc}, - {"Float", (PyCFunction)psyco_Float, - METH_VARARGS, psyco_Float_doc}, - {"Decimal", (PyCFunction)psyco_Decimal, - METH_VARARGS, psyco_Decimal_doc}, - {"Binary", (PyCFunction)psyco_Binary, - METH_VARARGS, psyco_Binary_doc}, {"Date", (PyCFunction)psyco_Date, METH_VARARGS, psyco_Date_doc}, {"Time", (PyCFunction)psyco_Time, @@ -704,8 +690,6 @@ static PyMethodDef psycopgMethods[] = { METH_VARARGS, psyco_TimeFromTicks_doc}, {"TimestampFromTicks", (PyCFunction)psyco_TimestampFromTicks, METH_VARARGS, psyco_TimestampFromTicks_doc}, - {"List", (PyCFunction)psyco_List, - METH_VARARGS, psyco_List_doc}, {"DateFromPy", (PyCFunction)psyco_DateFromPy, METH_VARARGS, psyco_DateFromPy_doc}, @@ -912,6 +896,14 @@ INIT_MODULE(_psycopg)(void) PyModule_AddObject(module, "Notify", (PyObject*)¬ifyType); PyModule_AddObject(module, "Xid", (PyObject*)&xidType); PyModule_AddObject(module, "Diagnostics", (PyObject*)&diagnosticsType); + PyModule_AddObject(module, "AsIs", (PyObject*)&asisType); + PyModule_AddObject(module, "Binary", (PyObject*)&binaryType); + PyModule_AddObject(module, "Boolean", (PyObject*)&pbooleanType); + PyModule_AddObject(module, "Decimal", (PyObject*)&pdecimalType); + PyModule_AddObject(module, "Int", (PyObject*)&pintType); + PyModule_AddObject(module, "Float", (PyObject*)&pfloatType); + PyModule_AddObject(module, "List", (PyObject*)&listType); + PyModule_AddObject(module, "QuotedString", (PyObject*)&qstringType); #ifdef PSYCOPG_EXTENSIONS PyModule_AddObject(module, "lobject", (PyObject*)&lobjectType); #endif