mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)
This commit is contained in:
parent
882fcede83
commit
72d3cc94cd
15 changed files with 116 additions and 119 deletions
14
Python/generated_cases.c.h
generated
14
Python/generated_cases.c.h
generated
|
@ -2368,14 +2368,14 @@
|
|||
next_instr += 1;
|
||||
INSTRUCTION_STATS(DELETE_GLOBAL);
|
||||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
|
||||
int err;
|
||||
err = PyDict_DelItem(GLOBALS(), name);
|
||||
int err = PyDict_Pop(GLOBALS(), name, NULL);
|
||||
// Can't use ERROR_IF here.
|
||||
if (err != 0) {
|
||||
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
|
||||
_PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
|
||||
NAME_ERROR_MSG, name);
|
||||
}
|
||||
if (err < 0) {
|
||||
GOTO_ERROR(error);
|
||||
}
|
||||
if (err == 0) {
|
||||
_PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
|
||||
NAME_ERROR_MSG, name);
|
||||
GOTO_ERROR(error);
|
||||
}
|
||||
DISPATCH();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue