summaryrefslogtreecommitdiff
path: root/Modules/_datetimemodule.c
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2020-09-23 12:43:45 -0600
committerGitHub <noreply@github.com>2020-09-23 14:43:45 -0400
commit2e4dd336e5b50fd30947fdecb605ddcd71f7f6f5 (patch)
tree7b8e1b98c94d77ffcdcfc61645c6b40f5ebd44ab /Modules/_datetimemodule.c
parent9c4eac7f02ddcf32fc1cdaf7c08c37fe9718c1fb (diff)
downloadcpython-git-2e4dd336e5b50fd30947fdecb605ddcd71f7f6f5.tar.gz
bpo-30155: Add macros to get tzinfo from datetime instances (GH-21633)
Add PyDateTime_DATE_GET_TZINFO() and PyDateTime_TIME_GET_TZINFO() macros.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r--Modules/_datetimemodule.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 74a54e74ae..0631272429 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -115,14 +115,9 @@ class datetime.IsoCalendarDate "PyDateTime_IsoCalendarDate *" "&PyDateTime_IsoCa
#define SET_TD_SECONDS(o, v) ((o)->seconds = (v))
#define SET_TD_MICROSECONDS(o, v) ((o)->microseconds = (v))
-/* p is a pointer to a time or a datetime object; HASTZINFO(p) returns
- * p->hastzinfo.
- */
-#define HASTZINFO(p) (((_PyDateTime_BaseTZInfo *)(p))->hastzinfo)
-#define GET_TIME_TZINFO(p) (HASTZINFO(p) ? \
- ((PyDateTime_Time *)(p))->tzinfo : Py_None)
-#define GET_DT_TZINFO(p) (HASTZINFO(p) ? \
- ((PyDateTime_DateTime *)(p))->tzinfo : Py_None)
+#define HASTZINFO _PyDateTime_HAS_TZINFO
+#define GET_TIME_TZINFO PyDateTime_TIME_GET_TZINFO
+#define GET_DT_TZINFO PyDateTime_DATE_GET_TZINFO
/* M is a char or int claiming to be a valid month. The macro is equivalent
* to the two-sided Python test
* 1 <= M <= 12