[3.7] bpo-10381: Test that new_timezone can return the UTC singleton (gh-5318) by miss-islington · Pull Request #5819 · python/cpython
static PyObject * get_timezones_offset_zero(PyObject *self, PyObject *args) { PyObject *offset = PyDelta_FromDSU(0, 0, 0); PyObject *name = PyUnicode_FromString("");
// These two should return the UTC singleton PyObject *utc_singleton_0 = PyTimeZone_FromOffset(offset); PyObject *utc_singleton_1 = PyTimeZone_FromOffsetAndName(offset, NULL);
// This one will return +00:00 zone, but not the UTC singleton PyObject *non_utc_zone = PyTimeZone_FromOffsetAndName(offset, name);
Py_DecRef(offset); Py_DecRef(name);
PyObject *rv = PyTuple_New(3); PyTuple_SET_ITEM(rv, 0, utc_singleton_0); PyTuple_SET_ITEM(rv, 1, utc_singleton_1); PyTuple_SET_ITEM(rv, 2, non_utc_zone);
return rv; }
static PyObject * get_timezone_utc_capi(PyObject* self, PyObject *args) { int macro = 0;