Skip to content

Commit

Permalink
Python 3.10 doesn't look up __annotations__ in getset descr?
Browse files Browse the repository at this point in the history
  • Loading branch information
tiran committed Oct 1, 2021
1 parent beed64b commit 29d492f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/wrapt/_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
#define WRAPT_HEAPTYPE_STRONG_TYPEREF 1
#endif

/* Python 3.10 needs extra __annotations__ entries in PyGetSetDef of
* subclasses. */
#if PY_VERSION_HEX >= 0x030a0000
#define WRAPT_ANNOTATIONS_GETSET_WORKAROUND 1
#endif

/* ------------------------------------------------------------------------- */

typedef struct {
Expand Down Expand Up @@ -1701,6 +1707,10 @@ static PyGetSetDef WraptCallableObjectProxy_getset[] = {
(setter)WraptObjectProxy_set_module, 0 },
{ "__doc__", (getter)WraptObjectProxy_get_doc,
(setter)WraptObjectProxy_set_doc, 0 },
#ifdef WRAPT_ANNOTATIONS_GETSET_WORKAROUND
{ "__annotations__", (getter)WraptObjectProxy_get_annotations,
(setter)WraptObjectProxy_set_annotations, 0 },
#endif
{ NULL },
};

Expand Down Expand Up @@ -1912,6 +1922,10 @@ static PyGetSetDef WraptPartialCallableObjectProxy_getset[] = {
(setter)WraptObjectProxy_set_module, 0 },
{ "__doc__", (getter)WraptObjectProxy_get_doc,
(setter)WraptObjectProxy_set_doc, 0 },
#ifdef WRAPT_ANNOTATIONS_GETSET_WORKAROUND
{ "__annotations__", (getter)WraptObjectProxy_get_annotations,
(setter)WraptObjectProxy_set_annotations, 0 },
#endif
{ NULL },
};

Expand Down Expand Up @@ -2448,6 +2462,10 @@ static PyGetSetDef WraptFunctionWrapperBase_getset[] = {
(setter)WraptObjectProxy_set_module, 0 },
{ "__doc__", (getter)WraptObjectProxy_get_doc,
(setter)WraptObjectProxy_set_doc, 0 },
#ifdef WRAPT_ANNOTATIONS_GETSET_WORKAROUND
{ "__annotations__", (getter)WraptObjectProxy_get_annotations,
(setter)WraptObjectProxy_set_annotations, 0 },
#endif
{ "_self_instance", (getter)WraptFunctionWrapperBase_get_self_instance,
NULL, 0 },
{ "_self_wrapper", (getter)WraptFunctionWrapperBase_get_self_wrapper,
Expand Down Expand Up @@ -2637,6 +2655,10 @@ static PyGetSetDef WraptBoundFunctionWrapper_getset[] = {
(setter)WraptObjectProxy_set_module, 0 },
{ "__doc__", (getter)WraptObjectProxy_get_doc,
(setter)WraptObjectProxy_set_doc, 0 },
#ifdef WRAPT_ANNOTATIONS_GETSET_WORKAROUND
{ "__annotations__", (getter)WraptObjectProxy_get_annotations,
(setter)WraptObjectProxy_set_annotations, 0 },
#endif
{ NULL },
};

Expand Down Expand Up @@ -2747,6 +2769,10 @@ static PyGetSetDef WraptFunctionWrapper_getset[] = {
(setter)WraptObjectProxy_set_module, 0 },
{ "__doc__", (getter)WraptObjectProxy_get_doc,
(setter)WraptObjectProxy_set_doc, 0 },
#ifdef WRAPT_ANNOTATIONS_GETSET_WORKAROUND
{ "__annotations__", (getter)WraptObjectProxy_get_annotations,
(setter)WraptObjectProxy_set_annotations, 0 },
#endif
{ NULL },
};

Expand Down

0 comments on commit 29d492f

Please sign in to comment.