Skip to content

Commit 2c20871

Browse files
committed
Drop support for TimeZoneType in datetime C API
1 parent 8728bd7 commit 2c20871

File tree

5 files changed

+0
-44
lines changed

5 files changed

+0
-44
lines changed

Doc/c-api/datetime.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ Type-check macros:
7575
*NULL*.
7676
7777
78-
.. c:function:: int PyTimeZone_Check(PyObject *ob)
79-
80-
Return true if *ob* is of type :c:data:`PyDateTime_TimeZoneType` or a subtype of
81-
:c:data:`PyDateTime_TimeZoneType`. *ob* must not be *NULL*.
82-
83-
84-
.. c:function:: int PyTimeZone_CheckExact(PyObject *ob)
85-
86-
Return true if *ob* is of type :c:data:`PyDateTime_TimeZoneType`. *ob* must not be
87-
*NULL*.
88-
89-
9078
Macros to create objects:
9179
9280
.. c:function:: PyObject* PyDate_FromDate(int year, int month, int day)

Include/datetime.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ typedef struct {
154154
PyTypeObject *TimeType;
155155
PyTypeObject *DeltaType;
156156
PyTypeObject *TZInfoType;
157-
PyTypeObject *TimeZoneType;
158157

159158
/* singletons */
160159
PyObject *TimeZone_UTC;
@@ -199,9 +198,6 @@ typedef struct {
199198
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
200199
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
201200

202-
#define PyTimeZone_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeZoneType)
203-
#define PyTimeZone_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeZoneType)
204-
205201
#else
206202

207203
/* Define global variable for the C API and a macro for setting it. */
@@ -226,10 +222,6 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
226222
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
227223
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)
228224

229-
#define PyTimeZone_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeZoneType)
230-
#define PyTimeZone_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeZoneType)
231-
232-
233225
/* Macros for accessing constructors in a simplified fashion. */
234226
#define PyDate_FromDate(year, month, day) \
235227
PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)

Lib/test/datetimetester.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5622,24 +5622,6 @@ class TZInfoSubclass(tzinfo):
56225622
with self.subTest(arg=arg, exact=exact):
56235623
self.assertFalse(is_tzinfo(arg, exact))
56245624

5625-
def test_check_timezone(self):
5626-
tz = timezone(timedelta(hours=-5))
5627-
5628-
is_timezone = _testcapi.datetime_check_timezone
5629-
5630-
# Check the ones that should be valid
5631-
self.assertTrue(is_timezone(tz))
5632-
self.assertTrue(is_timezone(tz, True))
5633-
5634-
# Check that various other things are not time zones
5635-
args = [tuple(), list(), 1, '2011-01-01', tzinfo(),
5636-
date(2011, 1, 1), datetime(2011, 1, 1)]
5637-
5638-
for arg in args:
5639-
for exact in (True, False):
5640-
with self.subTest(arg=arg, exact=exact):
5641-
self.assertFalse(is_timezone(arg, exact))
5642-
56435625
def load_tests(loader, standard_tests, pattern):
56445626
standard_tests.addTest(ZoneInfoCompleteTest())
56455627
return standard_tests

Modules/_datetimemodule.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6036,7 +6036,6 @@ static PyDateTime_CAPI CAPI = {
60366036
&PyDateTime_TimeType,
60376037
&PyDateTime_DeltaType,
60386038
&PyDateTime_TZInfoType,
6039-
&PyDateTime_TimeZoneType,
60406039
NULL, // PyDatetime_TimeZone_UTC not initialized yet
60416040
new_date_ex,
60426041
new_datetime_ex,

Modules/_testcapimodule.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,10 +2266,6 @@ datetime_check_tzinfo(PyObject *self, PyObject *args) {
22662266
MAKE_DATETIME_CHECK_FUNC(PyTZInfo_Check, PyTZInfo_CheckExact)
22672267
}
22682268

2269-
static PyObject *
2270-
datetime_check_timezone(PyObject *self, PyObject *args) {
2271-
MAKE_DATETIME_CHECK_FUNC(PyTimeZone_Check, PyTimeZone_CheckExact)
2272-
}
22732269

22742270
/* Makes three variations on timezone representing UTC-5:
22752271
1. timezone with offset and name from PyDateTimeAPI
@@ -4526,7 +4522,6 @@ static PyMethodDef TestMethods[] = {
45264522
{"datetime_check_datetime", datetime_check_datetime, METH_VARARGS},
45274523
{"datetime_check_delta", datetime_check_delta, METH_VARARGS},
45284524
{"datetime_check_tzinfo", datetime_check_tzinfo, METH_VARARGS},
4529-
{"datetime_check_timezone", datetime_check_timezone, METH_VARARGS},
45304525
{"make_timezones_capi", make_timezones_capi, METH_NOARGS},
45314526
{"get_timezone_utc_capi", get_timezone_utc_capi, METH_NOARGS},
45324527
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},

0 commit comments

Comments
 (0)