Skip to content

Commit 4fe28d6

Browse files
committed
Merge branch 'dev/init-failure'
2 parents fb77bdc + 14e06d8 commit 4fe28d6

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Current release
44
What's new in psycopg 2.9.7 (unreleased)
55
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

7+
- Fix propagation of exceptions raised during module initialization
8+
(:ticket:`#1598`).
79
- Fix building when pg_config returns an empty string (:ticket:`#1599`).
810
- Wheel package compiled against OpenSSL 1.1.1v.
911

psycopg/psycopgmodule.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,32 +1001,35 @@ INIT_MODULE(_psycopg)(void)
10011001

10021002
/* initialize types and objects not exposed to the module */
10031003
Py_SET_TYPE(&typecastType, &PyType_Type);
1004-
if (0 > PyType_Ready(&typecastType)) { goto exit; }
1004+
if (0 > PyType_Ready(&typecastType)) { goto error; }
10051005

10061006
Py_SET_TYPE(&chunkType, &PyType_Type);
1007-
if (0 > PyType_Ready(&chunkType)) { goto exit; }
1007+
if (0 > PyType_Ready(&chunkType)) { goto error; }
10081008

10091009
Py_SET_TYPE(&errorType, &PyType_Type);
10101010
errorType.tp_base = (PyTypeObject *)PyExc_StandardError;
1011-
if (0 > PyType_Ready(&errorType)) { goto exit; }
1011+
if (0 > PyType_Ready(&errorType)) { goto error; }
10121012

1013-
if (!(psyco_null = Bytes_FromString("NULL"))) { goto exit; }
1013+
if (!(psyco_null = Bytes_FromString("NULL"))) { goto error; }
10141014

10151015
/* initialize the module */
10161016
module = PyModule_Create(&psycopgmodule);
1017-
if (!module) { goto exit; }
1017+
if (!module) { goto error; }
10181018

1019-
if (0 > add_module_constants(module)) { goto exit; }
1020-
if (0 > add_module_types(module)) { goto exit; }
1021-
if (0 > datetime_init()) { goto exit; }
1022-
if (0 > encodings_init(module)) { goto exit; }
1023-
if (0 > typecast_init(module)) { goto exit; }
1024-
if (0 > adapters_init(module)) { goto exit; }
1025-
if (0 > basic_errors_init(module)) { goto exit; }
1026-
if (0 > sqlstate_errors_init(module)) { goto exit; }
1019+
if (0 > add_module_constants(module)) { goto error; }
1020+
if (0 > add_module_types(module)) { goto error; }
1021+
if (0 > datetime_init()) { goto error; }
1022+
if (0 > encodings_init(module)) { goto error; }
1023+
if (0 > typecast_init(module)) { goto error; }
1024+
if (0 > adapters_init(module)) { goto error; }
1025+
if (0 > basic_errors_init(module)) { goto error; }
1026+
if (0 > sqlstate_errors_init(module)) { goto error; }
10271027

10281028
Dprintf("psycopgmodule: module initialization complete");
1029-
1030-
exit:
10311029
return module;
1030+
1031+
error:
1032+
if (module)
1033+
Py_DECREF(module);
1034+
return NULL;
10321035
}

0 commit comments

Comments
 (0)