Skip to content

Commit 3788b85

Browse files
committed
Change error return value to be more consistent with the rest of Python
1 parent d170256 commit 3788b85

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Objects/codeobject.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
780780

781781
if (!PyCode_Check(code)) {
782782
PyErr_BadInternalCall();
783-
return 1;
783+
return -1;
784784
}
785785

786786
o = (PyCodeObject*) code;
@@ -803,7 +803,7 @@ _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
803803
if (!PyCode_Check(code) || index < 0 ||
804804
index >= tstate->co_extra_user_count) {
805805
PyErr_BadInternalCall();
806-
return 1;
806+
return -1;
807807
}
808808

809809
o = (PyCodeObject*) code;
@@ -812,13 +812,13 @@ _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
812812
o->co_extra = (_PyCodeObjectExtra*) PyMem_Malloc(
813813
sizeof(_PyCodeObjectExtra));
814814
if (o->co_extra == NULL) {
815-
return 1;
815+
return -1;
816816
}
817817

818818
o->co_extra->ce_extras = PyMem_Malloc(
819819
tstate->co_extra_user_count * sizeof(void*));
820820
if (o->co_extra->ce_extras == NULL) {
821-
return 1;
821+
return -1;
822822
}
823823

824824
o->co_extra->ce_size = tstate->co_extra_user_count;
@@ -832,7 +832,7 @@ _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
832832
o->co_extra->ce_extras, tstate->co_extra_user_count * sizeof(void*));
833833

834834
if (o->co_extra->ce_extras == NULL) {
835-
return 1;
835+
return -1;
836836
}
837837

838838
o->co_extra->ce_size = tstate->co_extra_user_count;

0 commit comments

Comments
 (0)