Change error return value to be more consistent with the rest of Python

This commit is contained in:
Brett Cannon 2016-09-07 12:51:08 -07:00
parent d170256585
commit 3788b85628
1 changed files with 5 additions and 5 deletions

View File

@ -780,7 +780,7 @@ _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
if (!PyCode_Check(code)) {
PyErr_BadInternalCall();
return 1;
return -1;
}
o = (PyCodeObject*) code;
@ -803,7 +803,7 @@ _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
if (!PyCode_Check(code) || index < 0 ||
index >= tstate->co_extra_user_count) {
PyErr_BadInternalCall();
return 1;
return -1;
}
o = (PyCodeObject*) code;
@ -812,13 +812,13 @@ _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
o->co_extra = (_PyCodeObjectExtra*) PyMem_Malloc(
sizeof(_PyCodeObjectExtra));
if (o->co_extra == NULL) {
return 1;
return -1;
}
o->co_extra->ce_extras = PyMem_Malloc(
tstate->co_extra_user_count * sizeof(void*));
if (o->co_extra->ce_extras == NULL) {
return 1;
return -1;
}
o->co_extra->ce_size = tstate->co_extra_user_count;
@ -832,7 +832,7 @@ _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
o->co_extra->ce_extras, tstate->co_extra_user_count * sizeof(void*));
if (o->co_extra->ce_extras == NULL) {
return 1;
return -1;
}
o->co_extra->ce_size = tstate->co_extra_user_count;