summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-05-20 16:17:47 +0200
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-05-20 16:17:47 +0200
commit55aef83fa1bae9aa9f000c25c463e94fb9490e90 (patch)
treee099d884f6c75fea586ed7b51dbac768b3a5ea54
parent0f457a01d9eb61fc83be35ce9676ff200a90f470 (diff)
parent3487f627e2b8afb2e1dcd8abfc1b6ce94380b1bb (diff)
downloadpsycopg2-55aef83fa1bae9aa9f000c25c463e94fb9490e90.tar.gz
Merge branch 'sqlstate_errors'
-rw-r--r--NEWS1
-rw-r--r--psycopg/psycopgmodule.c9
2 files changed, 7 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 35044bc..bdd30df 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ What's new in psycopg 2.8.7
- Accept empty params as `~psycopg2.connect()` (:ticket:`#1250`).
- Fix attributes refcount in `Column` initialisation (:ticket:`#1252`).
+- Allow re-initialisation of static variables in the C module (:ticket:`#1267`).
What's new in psycopg 2.8.6
diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c
index 36fd1f9..d448d01 100644
--- a/psycopg/psycopgmodule.c
+++ b/psycopg/psycopgmodule.c
@@ -608,6 +608,10 @@ encodings_init(PyObject *module)
int rv = -1;
Dprintf("psycopgmodule: initializing encodings table");
+ if (psycoEncodings) {
+ Dprintf("encodings_init(): already called");
+ return 0;
+ }
if (!(psycoEncodings = PyDict_New())) { goto exit; }
Py_INCREF(psycoEncodings);
@@ -770,9 +774,8 @@ sqlstate_errors_init(PyObject *module)
Dprintf("psycopgmodule: initializing sqlstate exceptions");
if (sqlstate_errors) {
- PyErr_SetString(PyExc_SystemError,
- "sqlstate_errors_init(): already called");
- goto exit;
+ Dprintf("sqlstate_errors_init(): already called");
+ return 0;
}
if (!(errmodule = PyImport_ImportModule("psycopg2.errors"))) {
/* don't inject the exceptions into the errors module */