Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review comments.
  • Loading branch information
serhiy-storchaka committed Mar 7, 2024
commit 9109ccbcf015766096400094ca8f3ac86bbeba65
9 changes: 5 additions & 4 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,10 +1607,11 @@ _csv_unregister_dialect_impl(PyObject *module, PyObject *name)
{
_csvstate *module_state = get_csv_state(module);
int rc = PyDict_Pop(module_state->dialects, name, NULL);
if (rc <= 0) {
if (rc == 0) {
PyErr_Format(module_state->error_obj, "unknown dialect");
}
if (rc < 0) {
return NULL;
}
if (rc == 0) {
PyErr_Format(module_state->error_obj, "unknown dialect");
return NULL;
}
Py_RETURN_NONE;
Expand Down
3 changes: 2 additions & 1 deletion Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,9 @@ _localdummy_destroyed(PyObject *localweakref, PyObject *dummyweakref)
/* If the thread-local object is still alive and not being cleared,
remove the corresponding local dict */
if (self->dummies != NULL) {
if (PyDict_Pop(self->dummies, dummyweakref, NULL) < 0)
if (PyDict_Pop(self->dummies, dummyweakref, NULL) < 0) {
PyErr_WriteUnraisable((PyObject*)self);
}
}
Py_DECREF(self);
Py_RETURN_NONE;
Expand Down
4 changes: 2 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -17556,10 +17556,10 @@ posixmodule_exec(PyObject *m)
return -1;
}

if (PyDict_PopString(dct, "pwritev", NULL) == -1) {
if (PyDict_PopString(dct, "pwritev", NULL) < 0) {
return -1;
}
if (PyDict_PopString(dct, "preadv", NULL) == -1) {
if (PyDict_PopString(dct, "preadv", NULL) < 0) {
return -1;
}
}
Expand Down
14 changes: 7 additions & 7 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1928,19 +1928,19 @@ time_exec(PyObject *module)
return -1;
}

if (PyDict_PopString(dct, "clock_gettime", NULL) == -1) {
if (PyDict_PopString(dct, "clock_gettime", NULL) < 0) {
return -1;
}
if (PyDict_PopString(dct, "clock_gettime_ns", NULL) == -1) {
if (PyDict_PopString(dct, "clock_gettime_ns", NULL) < 0) {
return -1;
}
if (PyDict_PopString(dct, "clock_settime", NULL) == -1) {
if (PyDict_PopString(dct, "clock_settime", NULL) < 0) {
return -1;
}
if (PyDict_PopString(dct, "clock_settime_ns", NULL) == -1) {
if (PyDict_PopString(dct, "clock_settime_ns", NULL) < 0) {
return -1;
}
if (PyDict_PopString(dct, "clock_getres", NULL) == -1) {
if (PyDict_PopString(dct, "clock_getres", NULL) < 0) {
return -1;
}
}
Expand All @@ -1951,10 +1951,10 @@ time_exec(PyObject *module)
} else {
PyObject* dct = PyModule_GetDict(module);

if (PyDict_PopString(dct, "thread_time", NULL) == -1) {
if (PyDict_PopString(dct, "thread_time", NULL) < 0) {
return -1;
}
if (PyDict_PopString(dct, "thread_time_ns", NULL) == -1) {
if (PyDict_PopString(dct, "thread_time_ns", NULL) < 0) {
return -1;
}
}
Expand Down
7 changes: 5 additions & 2 deletions Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,9 +1006,12 @@ module_set_annotations(PyModuleObject *m, PyObject *value, void *Py_UNUSED(ignor
/* delete */
ret = PyDict_Pop(dict, &_Py_ID(__annotations__), NULL);
if (ret == 0) {
PyErr_SetString(PyExc_AttributeError, "__annotations__");
PyErr_SetObject(PyExc_AttributeError, &_Py_ID(__annotations__));
ret = -1;
}
else if (ret > 0) {
ret = 0;
}
ret = (ret > 0) ? 0 : -1;
}

exit:
Expand Down
2 changes: 2 additions & 0 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
if (res < 0) {
return -1;
}

PyType_Modified(type);
Comment thread
serhiy-storchaka marked this conversation as resolved.
if (abstract)
type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT;
Expand Down Expand Up @@ -1616,6 +1617,7 @@ type_set_annotations(PyTypeObject *type, PyObject *value, void *context)
if (result < 0) {
return -1;
}
Comment thread
serhiy-storchaka marked this conversation as resolved.

PyType_Modified(type);
return 0;
}
Expand Down
11 changes: 6 additions & 5 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,11 +1309,12 @@ dummy_func(
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyDict_Pop(GLOBALS(), name, NULL);
// Can't use ERROR_IF here.
if (err <= 0) {
if (err == 0) {
_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);
}
}
Expand Down
11 changes: 6 additions & 5 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.