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

property assumes that its subclasses have __dict__ #98963

Closed
Assignees
gpshead
Labels
3.12only security fixestopic-C-APItype-bugAn unexpected behavior, bug, or error
@encukou

Description

@encukou

property'stp_init hasthis code:

    if (Py_IS_TYPE(self, &PyProperty_Type)) {        Py_XSETREF(self->prop_doc, prop_doc);    } else {        /* If this is a property subclass, put __doc__           in dict of the subclass instance instead,           otherwise it gets shadowed by __doc__ in the           class's dict. */        /*...*/         PyObject_SetAttr((PyObject *)self, &_Py_ID(__doc__), prop_doc);        /*...*/    }

This assumes that subclasses ofproperty have a__dict__ (or a__doc__ attribute settable by other means). That is the case when subclassed using theclass statement, but might not be true using C.
A C-API reproducer is athttps://github.com/wjakob/inheritance_issue/blob/master/inheritance_issue.c

I don't see a good way to fix this. We could:

  • document that subclasses need to setPy_TPFLAGS_MANAGED_DICT (or provide a__doc__ descriptor), or
  • ignore theAttributeError, unless__doc__ was set explicitly?

Metadata

Metadata

Assignees

Labels

3.12only security fixestopic-C-APItype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp