summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-02-25 15:59:46 (GMT)
committerGitHub <noreply@github.com>2019-02-25 15:59:46 (GMT)
commita24107b04c1277e3c1105f98aff5bfa3a98b33a0 (patch)
tree55aa5a700e08e3ba27b0361df2b1043be5c4701a /Python/errors.c
parenta180b007d96fe68b32f11dec720fbd0cd5b6758a (diff)
downloadcpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.zip
cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.gz
cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.bz2
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c
index febe971..b8af1df 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -858,6 +858,7 @@ PyErr_Format(PyObject *exception, const char *format, ...)
PyObject *
PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
{
+ _Py_IDENTIFIER(__module__);
const char *dot;
PyObject *modulename = NULL;
PyObject *classname = NULL;
@@ -877,12 +878,15 @@ PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
if (dict == NULL)
goto failure;
}
- if (PyDict_GetItemString(dict, "__module__") == NULL) {
+ if (_PyDict_GetItemIdWithError(dict, &PyId___module__) == NULL) {
+ if (PyErr_Occurred()) {
+ goto failure;
+ }
modulename = PyUnicode_FromStringAndSize(name,
(Py_ssize_t)(dot-name));
if (modulename == NULL)
goto failure;
- if (PyDict_SetItemString(dict, "__module__", modulename) != 0)
+ if (_PyDict_SetItemId(dict, &PyId___module__, modulename) != 0)
goto failure;
}
if (PyTuple_Check(base)) {