.tp_doc = iso_calendar_date__doc__,
.tp_methods = iso_calendar_date_methods,
.tp_getset = iso_calendar_date_getset,
- .tp_base = &PyTuple_Type,
+ // .tp_base = &PyTuple_Type, // filled in PyInit__datetime
.tp_new = iso_calendar_date_new,
};
timezone_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
- &PyDateTime_TZInfoType, /* tp_base */
+ 0, /* tp_base; filled in PyInit__datetime */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
datetime_methods, /* tp_methods */
0, /* tp_members */
datetime_getset, /* tp_getset */
- &PyDateTime_DateType, /* tp_base */
+ 0, /* tp_base; filled in
+ PyInit__datetime */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
if (m == NULL)
return NULL;
+ // `&...` is not a constant expression according to a strict reading
+ // of C standards. Fill tp_base at run-time rather than statically.
+ // See https://bugs.python.org/issue40777
+ PyDateTime_IsoCalendarDateType.tp_base = &PyTuple_Type;
+ PyDateTime_TimeZoneType.tp_base = &PyDateTime_TZInfoType;
+ PyDateTime_DateTimeType.tp_base = &PyDateTime_DateType;
PyTypeObject *types[] = {
&PyDateTime_DateType,