[New-bugs-announce] [issue45319] Possible regression in __annotations__ descr for heap type subclasses

Christian Heimes report at bugs.python.org
Wed Sep 29 07:51:39 EDT 2021

New submission from Christian Heimes <lists at cheimes.de>:

While I was working on a patch to port wrapt to limited API and stable ABI, I noticed a possible regression in __annotations__ PyGetSetDef. It looks like C heap type subclasses no longer inherit the __annotations__ descriptor from a C heap type parent class. A gdb session confirmed that 3.10 no longer calls the WraptObjectProxy_set_annotations setter of the parent class while 3.9 does.

I had to add 

    { "__annotations__",    (getter)WraptObjectProxy_get_annotations,
                            (setter)WraptObjectProxy_set_annotations, 0},

to PyGetSetDef of the child class in order to fix the behavior. Python 3.9 and older work as expected.

You can reproduce the behavior by disabling WRAPT_ANNOTATIONS_GETSET_WORKAROUND and run "tox -e py310-install-extensions". The PR is https://github.com/GrahamDumpleton/wrapt/pull/187.

components: C API
keywords: 3.10regression
messages: 402855
nosy: christian.heimes, pablogsal
priority: normal
severity: normal
stage: test needed
status: open
title: Possible regression in __annotations__ descr for heap type subclasses
type: behavior
versions: Python 3.10, Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list