FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Subtypes of extension type appear to inherit Py_TPFLAGS_DISALLOW_INSTANTIATION flag · Issue #96746 · python/cpython · GitHub

Repository navigation

Subtypes of extension type appear to inherit Py_TPFLAGS_DISALLOW_INSTANTIATION flag #96746

Description

When Py_TPFLAGS_BASETYPE and Py_TPFLAGS_DISALLOW_INSTANTIATION flags are set on extension type tp_flags field, attempt to create type subclass instance fails:

>>> import _foo
>>> class Bar(_foo.Foo): pass
... 
>>> Bar()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot create 'Bar' instances

According to documentation, it shouldn't happen:
https://docs.python.org/3/c-api/typeobj.html#Py_TPFLAGS_DISALLOW_INSTANTIATION

Extension code example:
_foo.c.txt

Tested on 3.10.3 and 3.12.0a0.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL