Skip to content

Commit 2af6677

Browse files
committed
Adjust return values
1 parent 1e7d7e9 commit 2af6677

File tree

8 files changed

+146
-203
lines changed

8 files changed

+146
-203
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

Lines changed: 98 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/typeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,12 +2786,12 @@ _PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self)
27862786
_PyType_LookupStackRefAndVersion(Py_TYPE(self), attr, &method_and_self[0]);
27872787
PyObject *method_o = PyStackRef_AsPyObjectBorrow(method_and_self[0]);
27882788
if (method_o == NULL) {
2789-
return -1;
2789+
return 0;
27902790
}
27912791

27922792
if (_PyType_HasFeature(Py_TYPE(method_o), Py_TPFLAGS_METHOD_DESCRIPTOR)) {
27932793
/* Avoid temporary PyMethodObject */
2794-
return 0;
2794+
return 1;
27952795
}
27962796

27972797
descrgetfunc f = Py_TYPE(method_o)->tp_descr_get;
@@ -2804,7 +2804,7 @@ _PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self)
28042804
method_and_self[0] = PyStackRef_FromPyObjectSteal(func);
28052805
}
28062806
PyStackRef_CLEAR(method_and_self[1]); // clear self
2807-
return 0;
2807+
return 1;
28082808
}
28092809

28102810
static int

Python/bytecodes.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,33 +3365,23 @@ dummy_func(
33653365
_FOR_ITER_GEN_FRAME +
33663366
_PUSH_FRAME;
33673367

3368-
op(_INSERT_NULL, (arg -- arg1, arg2)) {
3369-
arg1 = PyStackRef_NULL;
3370-
arg2 = arg;
3371-
DEAD(arg);
3372-
}
3373-
3374-
op(_LOAD_SPECIAL, (null, self -- method_and_self[2])) {
3375-
method_and_self[0] = null;
3376-
method_and_self[1] = self;
3368+
inst(LOAD_SPECIAL, (owner -- method_and_self[2])) {
3369+
method_and_self[0] = PyStackRef_NULL;
3370+
method_and_self[1] = owner;
33773371
PyObject *name = _Py_SpecialMethods[oparg].name;
33783372
int err = _PyObject_LookupSpecialMethod(name, method_and_self);
33793373
if (err < 0) {
3380-
if (!_PyErr_Occurred(tstate)) {
3381-
_PyErr_Format(tstate, PyExc_TypeError,
3382-
_Py_SpecialMethods[oparg].error,
3383-
PyStackRef_TYPE(method_and_self[1])->tp_name);
3384-
ERROR_NO_POP();
3385-
}
3374+
ERROR_NO_POP();
3375+
}
3376+
else if (err == 0) {
3377+
_PyErr_Format(tstate, PyExc_TypeError,
3378+
_Py_SpecialMethods[oparg].error,
3379+
PyStackRef_TYPE(method_and_self[1])->tp_name);
33863380
ERROR_NO_POP();
33873381
}
33883382
INPUTS_DEAD();
33893383
}
33903384

3391-
macro(LOAD_SPECIAL) =
3392-
_INSERT_NULL +
3393-
_LOAD_SPECIAL;
3394-
33953385
inst(WITH_EXCEPT_START, (exit_func, exit_self, lasti, unused, val -- exit_func, exit_self, lasti, unused, val, res)) {
33963386
/* At the top of the stack are 4 values:
33973387
- val: TOP = exc_info()

0 commit comments

Comments
 (0)