Skip to content

Commit 19e02c2

Browse files
Work around specialization
1 parent bc9d23c commit 19e02c2

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

Python/bytecodes.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,14 +2288,20 @@ dummy_func(
22882288
STAT_INC(LOAD_SUPER_ATTR, hit);
22892289
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
22902290
PyTypeObject *cls = (PyTypeObject *)class;
2291-
int method_found = 0;
2292-
PyObject *attr_o = _PySuper_Lookup(cls, self, name, NULL);
2291+
// Note: not actually a pointer, just so that we can use restrict on it.
2292+
int *Py_MSVC_RESTRICT method_found = NULL;
2293+
PyObject *attr_o = _PySuper_Lookup(cls, self, name,
2294+
Py_TYPE(self)->tp_getattro == PyObject_GenericGetAttr ? (int *)&method_found : NULL);
22932295
if (attr_o == NULL) {
22942296
ERROR_NO_POP();
22952297
}
2296-
PyStackRef_CLOSE(self_st);
2297-
self_or_null = PyStackRef_NULL;
2298-
2298+
if (method_found) {
2299+
self_or_null = self_st; // transfer ownership
2300+
DEAD(self_st);
2301+
} else {
2302+
PyStackRef_CLOSE(self_st);
2303+
self_or_null = PyStackRef_NULL;
2304+
}
22992305
DECREF_INPUTS();
23002306

23012307
attr = PyStackRef_FromPyObjectSteal(attr_o);

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)