Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134043: add_PyObject_GetMethodStackRef#134044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kumaraditya303 merged 8 commits intopython:mainfromkumaraditya303:stackref-call
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from1 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
PrevPrevious commit
NextNext commit
cleanup
  • Loading branch information
@kumaraditya303
kumaraditya303 committedMay 23, 2025
commitf9d2f2842c3e68de4feb7d94eb723cf1f667f532
24 changes: 15 additions & 9 deletionsObjects/call.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -871,19 +871,22 @@ PyObject_CallMethodObjArgs(PyObject *obj, PyObject *name, ...)
return null_error(tstate);
}

PyObject *callable = NULL;
int is_method = _PyObject_GetMethod(obj, name, &callable);
if (callable == NULL) {
_PyCStackRef method;
_PyThreadState_PushCStackRef(tstate, &method);
int is_method = _PyObject_GetMethodStackRef(tstate, obj, name, &method.ref);
if (PyStackRef_IsNull(method.ref)) {
_PyThreadState_PopCStackRef(tstate, &method);
return NULL;
}
PyObject *callable = PyStackRef_AsPyObjectBorrow(method.ref);
obj = is_method ? obj : NULL;

va_list vargs;
va_start(vargs, name);
PyObject *result = object_vacall(tstate, obj, callable, vargs);
va_end(vargs);

Py_DECREF(callable);
_PyThreadState_PopCStackRef(tstate, &method);
return result;
}

Expand All@@ -900,20 +903,23 @@ _PyObject_CallMethodIdObjArgs(PyObject *obj, _Py_Identifier *name, ...)
if (!oname) {
return NULL;
}

PyObject *callable = NULL;
int is_method = _PyObject_GetMethod(obj, oname, &callable);
if (callable == NULL) {
_PyCStackRef method;
_PyThreadState_PushCStackRef(tstate, &method);
int is_method = _PyObject_GetMethodStackRef(tstate, obj, oname, &method.ref);
if (PyStackRef_IsNull(method.ref)) {
_PyThreadState_PopCStackRef(tstate, &method);
return NULL;
}
PyObject *callable = PyStackRef_AsPyObjectBorrow(method.ref);

obj = is_method ? obj : NULL;

va_list vargs;
va_start(vargs, name);
PyObject *result = object_vacall(tstate, obj, callable, vargs);
va_end(vargs);

Py_DECREF(callable);
_PyThreadState_PopCStackRef(tstate, &method);
return result;
}

Expand Down
19 changes: 8 additions & 11 deletionsObjects/object.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1670,7 +1670,6 @@ _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
{
int meth_found = 0;

int ret = 0;
assert(PyStackRef_IsNull(*method));

PyTypeObject *tp = Py_TYPE(obj);
Expand DownExpand Up@@ -1703,7 +1702,7 @@ _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
if (value != NULL) {
*method = PyStackRef_FromPyObjectSteal(value);
}
goto exit;
return 0;
}
}
}
Expand All@@ -1713,7 +1712,7 @@ _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
if (attr != NULL) {
PyStackRef_CLEAR(*method);
*method = PyStackRef_FromPyObjectSteal(attr);
goto exit;
return 0;
}
dict = NULL;
}
Expand All@@ -1740,16 +1739,15 @@ _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
if (value != NULL) {
*method = PyStackRef_FromPyObjectSteal(value);
}
goto exit;
return 0;
}
// not found
Py_DECREF(dict);
}

if (meth_found) {
ret = 1;
assert(!PyStackRef_IsNull(*method));
goto exit;
return 1;
}

if (f != NULL) {
Expand All@@ -1758,22 +1756,21 @@ _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
if (value) {
*method = PyStackRef_FromPyObjectSteal(value);
}
goto exit;
return 0;
}

if (descr != NULL) {
assert(!PyStackRef_IsNull(*method));
goto exit;
return 0;
}

PyErr_Format(PyExc_AttributeError,
"'%.100s' object has no attribute '%U'",
tp->tp_name, name);

_PyObject_SetAttributeErrorContext(obj, name);
PyStackRef_CLEAR(*method);
exit:
return ret;
assert(PyStackRef_IsNull(*method));
return 0;
}


Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp