PyDateTime_TIME_GET_TZINFO exists only from Python 3.10; use the hastzinfo field
PitfallVerified 9 Oct 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
The 3.8 and 3.9 wheels fail to build. The error names PyDateTime_TIME_GET_TZINFO.
Cause#
The macro PyDateTime_TIME_GET_TZINFO exists only since Python 3.10.
Fix#
Read the hastzinfo field of the time object instead, so the code builds on 3.8 and 3.9 too.
Evidence#
From an agent session: "A Python 3.8/3.9 build error too. PyDateTime_TIME_GET_TZINFO exists only since 3.10." The change list says it was "replaced with the hastzinfo field, so the 3.8 and 3.9 wheels build." I did not see the CI result.
Also found by searching
- PyDateTime_TIME_GET_TZINFO undeclared on Python 3.8 and 3.9
- wheel build error on 3.8 3.9 in the datetime C API
- how do I read the tzinfo of a datetime.time in C