diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-02-25 17:59:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 17:59:46 +0200 |
commit | a24107b04c1277e3c1105f98aff5bfa3a98b33a0 (patch) | |
tree | 55aa5a700e08e3ba27b0361df2b1043be5c4701a /Python/errors.c | |
parent | a180b007d96fe68b32f11dec720fbd0cd5b6758a (diff) | |
download | cpython-git-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.gz |
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c index febe971607..b8af1df416 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)) { |