[3.15] gh-149481: skip FOR_ITER inline specialization for Python __next__ (GH-149491) (#149523)

gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` (GH-149491)
(cherry picked from commit 49918f5b0c)

Co-authored-by: Neko Asakura <neko.asakura@outlook.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
This commit is contained in:
Miss Islington (bot) 2026-05-08 04:08:12 +02:00 committed by GitHub
parent b311ea8691
commit 5cb915da44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 3 deletions

View file

@ -2,6 +2,7 @@
#include "pycore_long.h"
#include "pycore_opcode_utils.h"
#include "pycore_optimizer.h"
#include "pycore_typeobject.h"
#include "pycore_uops.h"
#include "pycore_uop_ids.h"
#include "internal/pycore_moduleobject.h"
@ -1459,7 +1460,8 @@ dummy_func(void) {
type = sym_get_probable_type(iter);
definite = false;
}
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL
&& !_PyType_HasSlotTpIternext(type)) {
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
_Py_BloomFilter_Add(dependencies, type);
if (!definite) {

View file

@ -3706,7 +3706,8 @@
type = sym_get_probable_type(iter);
definite = false;
}
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL
&& !_PyType_HasSlotTpIternext(type)) {
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
_Py_BloomFilter_Add(dependencies, type);
if (!definite) {