summaryrefslogtreecommitdiff
path: root/psycopg
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2018-12-31 00:28:58 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-01-21 02:41:58 +0000
commit594df09a63267fe2ce960459f5ce2362b6e27c67 (patch)
tree3afb3157a33e2614d272ee13b89317d885bffdb0 /psycopg
parent2ad2b27065514870b890a7ed0a94a4da096f7f98 (diff)
downloadpsycopg2-594df09a63267fe2ce960459f5ce2362b6e27c67.tar.gz
More straightforward semantics for psyco_GetDecimalType
Raise an exception when returning NULL, leave the caller cleaning it.
Diffstat (limited to 'psycopg')
-rw-r--r--psycopg/typecast_basic.c1
-rw-r--r--psycopg/utils.c9
2 files changed, 4 insertions, 6 deletions
diff --git a/psycopg/typecast_basic.c b/psycopg/typecast_basic.c
index ff4cf7b..170ee45 100644
--- a/psycopg/typecast_basic.c
+++ b/psycopg/typecast_basic.c
@@ -148,6 +148,7 @@ typecast_DECIMAL_cast(const char *s, Py_ssize_t len, PyObject *curs)
Py_DECREF(decimalType);
}
else {
+ PyErr_Clear();
res = PyObject_CallFunction((PyObject*)&PyFloat_Type, "s", buffer);
}
PyMem_Free(buffer);
diff --git a/psycopg/utils.c b/psycopg/utils.c
index 7f8e0ad..81171bd 100644
--- a/psycopg/utils.c
+++ b/psycopg/utils.c
@@ -427,12 +427,10 @@ psyco_is_main_interp(void)
/* psyco_GetDecimalType
- Return a new reference to the adapter for decimal type.
+ Return a new reference to the decimal type.
- If decimals should be used but the module import fails, fall back on
- the float type.
-
- If decimals are not to be used, return NULL.
+ The function returns a cached version of the object, but only in the main
+ interpreter because subinterpreters are confusing.
*/
PyObject *
@@ -456,7 +454,6 @@ psyco_GetDecimalType(void)
Py_DECREF(decimal);
}
else {
- PyErr_Clear();
decimalType = NULL;
}