Skip to content

In _GUARD_TYPE_VERSION, can type_version be 0? #110319

@gvanrossum

Description

@gvanrossum

Currently _GUARD_TYPE_VERSION looks like this in Python/bytecodes.c:

        op(_GUARD_TYPE_VERSION, (type_version/2, owner -- owner)) {
            PyTypeObject *tp = Py_TYPE(owner);
            assert(type_version != 0);
            DEOPT_IF(tp->tp_version_tag != type_version);
        }

My question is about that assert. As I split more opcodes into uops, I find some variations of this -- a few opcodes didn't have such an assert, a few others have it after the DEOPT_IF call. Are there really places where the cache can contain a type_version field that is zero? And if so, should those match a zero tp_version_tag in the type?

@markshannon @brandtbucher

Linked PRs

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions