diff options
author | Peter Eisentraut | 2017-10-31 14:49:36 +0000 |
---|---|---|
committer | Peter Eisentraut | 2017-11-18 18:39:53 +0000 |
commit | d0aa965c0a0ac2ff7906ae1b1dad50a7952efa56 (patch) | |
tree | 0a464efb705e7df59aefb68bb7cbcba3772fb9fa /src/pl/plpython/plpy_main.c | |
parent | 976a1a48fc35cde3c750982be64f872c4de4d343 (diff) |
Consistently catch errors from Python _New() functions
Python Py*_New() functions can fail and return NULL in out-of-memory
conditions. The previous code handled that inconsistently or not at
all. This change organizes that better. If we are in a function that
is called from Python, we just check for failure and return NULL
ourselves, which will cause any exception information to be passed up.
If we are called from PostgreSQL, we consistently create an "out of
memory" error.
Reviewed-by: Tom Lane <[email protected]>
Diffstat (limited to 'src/pl/plpython/plpy_main.c')
-rw-r--r-- | src/pl/plpython/plpy_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c index 29db90e4489..32d23ae5b6d 100644 --- a/src/pl/plpython/plpy_main.c +++ b/src/pl/plpython/plpy_main.c @@ -167,7 +167,7 @@ PLy_init_interp(void) PLy_interp_globals = PyModule_GetDict(mainmod); PLy_interp_safe_globals = PyDict_New(); if (PLy_interp_safe_globals == NULL) - PLy_elog(ERROR, "could not create globals"); + PLy_elog(ERROR, NULL); PyDict_SetItemString(PLy_interp_globals, "GD", PLy_interp_safe_globals); Py_DECREF(mainmod); if (PLy_interp_globals == NULL || PyErr_Occurred()) |