Skip to content

Commit 9fee212

Browse files
committed
fix UBSan failures for PyDateTime_TZInfo
1 parent 1aeeff8 commit 9fee212

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Modules/_datetimemodule.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,19 +4043,19 @@ tzinfo_nogo(const char* methodname)
40434043
/* Methods. A subclass must implement these. */
40444044

40454045
static PyObject *
4046-
tzinfo_tzname(PyDateTime_TZInfo *self, PyObject *dt)
4046+
tzinfo_tzname(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(dt))
40474047
{
40484048
return tzinfo_nogo("tzname");
40494049
}
40504050

40514051
static PyObject *
4052-
tzinfo_utcoffset(PyDateTime_TZInfo *self, PyObject *dt)
4052+
tzinfo_utcoffset(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(dt))
40534053
{
40544054
return tzinfo_nogo("utcoffset");
40554055
}
40564056

40574057
static PyObject *
4058-
tzinfo_dst(PyDateTime_TZInfo *self, PyObject *dt)
4058+
tzinfo_dst(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(dt))
40594059
{
40604060
return tzinfo_nogo("dst");
40614061
}
@@ -4068,7 +4068,7 @@ static PyObject *datetime_utcoffset(PyObject *self, PyObject *);
40684068
static PyObject *datetime_dst(PyObject *self, PyObject *);
40694069

40704070
static PyObject *
4071-
tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt)
4071+
tzinfo_fromutc(PyObject *self, PyObject *dt)
40724072
{
40734073
PyObject *result = NULL;
40744074
PyObject *off = NULL, *dst = NULL;
@@ -4079,7 +4079,7 @@ tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt)
40794079
"fromutc: argument must be a datetime");
40804080
return NULL;
40814081
}
4082-
if (GET_DT_TZINFO(dt) != (PyObject *)self) {
4082+
if (GET_DT_TZINFO(dt) != self) {
40834083
PyErr_SetString(PyExc_ValueError, "fromutc: dt.tzinfo "
40844084
"is not self");
40854085
return NULL;
@@ -4176,20 +4176,20 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
41764176

41774177
static PyMethodDef tzinfo_methods[] = {
41784178

4179-
{"tzname", (PyCFunction)tzinfo_tzname, METH_O,
4179+
{"tzname", tzinfo_tzname, METH_O,
41804180
PyDoc_STR("datetime -> string name of time zone.")},
41814181

4182-
{"utcoffset", (PyCFunction)tzinfo_utcoffset, METH_O,
4182+
{"utcoffset", tzinfo_utcoffset, METH_O,
41834183
PyDoc_STR("datetime -> timedelta showing offset from UTC, negative "
41844184
"values indicating West of UTC")},
41854185

4186-
{"dst", (PyCFunction)tzinfo_dst, METH_O,
4186+
{"dst", tzinfo_dst, METH_O,
41874187
PyDoc_STR("datetime -> DST offset as timedelta positive east of UTC.")},
41884188

4189-
{"fromutc", (PyCFunction)tzinfo_fromutc, METH_O,
4189+
{"fromutc", tzinfo_fromutc, METH_O,
41904190
PyDoc_STR("datetime in UTC -> datetime in local time.")},
41914191

4192-
{"__reduce__", tzinfo_reduce, METH_NOARGS,
4192+
{"__reduce__", tzinfo_reduce, METH_NOARGS,
41934193
PyDoc_STR("-> (cls, state)")},
41944194

41954195
{NULL, NULL}

0 commit comments

Comments
 (0)