{
PyObject *offset = PyDelta_FromDSU(0, -18000, 0);
PyObject *name = PyUnicode_FromString("EST");
+ if (offset == NULL || name == NULL) {
+ Py_XDECREF(offset);
+ Py_XDECREF(name);
+ return NULL;
+ }
PyObject *est_zone_capi = PyDateTimeAPI->TimeZone_FromTimeZone(offset, name);
PyObject *est_zone_macro = PyTimeZone_FromOffsetAndName(offset, name);
PyObject *est_zone_macro_noname = PyTimeZone_FromOffset(offset);
-
- Py_DecRef(offset);
- Py_DecRef(name);
-
+ Py_DECREF(offset);
+ Py_DECREF(name);
+ if (est_zone_capi == NULL || est_zone_macro == NULL ||
+ est_zone_macro_noname == NULL)
+ {
+ goto error;
+ }
PyObject *rv = PyTuple_New(3);
if (rv == NULL) {
- return NULL;
+ goto error;
}
PyTuple_SET_ITEM(rv, 0, est_zone_capi);
PyTuple_SET_ITEM(rv, 2, est_zone_macro_noname);
return rv;
+error:
+ Py_XDECREF(est_zone_capi);
+ Py_XDECREF(est_zone_macro);
+ Py_XDECREF(est_zone_macro_noname);
+ return NULL;
}
static PyObject *
{
PyObject *offset = PyDelta_FromDSU(0, 0, 0);
PyObject *name = PyUnicode_FromString("");
+ if (offset == NULL || name == NULL) {
+ Py_XDECREF(offset);
+ Py_XDECREF(name);
+ return NULL;
+ }
// These two should return the UTC singleton
PyObject *utc_singleton_0 = PyTimeZone_FromOffset(offset);
// 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);
+ Py_DECREF(offset);
+ Py_DECREF(name);
+ if (utc_singleton_0 == NULL || utc_singleton_1 == NULL ||
+ non_utc_zone == NULL)
+ {
+ goto error;
+ }
PyObject *rv = PyTuple_New(3);
+ if (rv == NULL) {
+ goto error;
+ }
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;
+error:
+ Py_XDECREF(utc_singleton_0);
+ Py_XDECREF(utc_singleton_1);
+ Py_XDECREF(non_utc_zone);
+ return NULL;
}
static PyObject *
for (i = 0; i < count; i++) {
v = PyLong_FromLong(i);
if (v == NULL) {
- return -1;
+ goto error;
}
if (PyDict_SetItem(dict, v, v) < 0) {
Py_DECREF(v);
- return -1;
+ goto error;
}
Py_DECREF(v);
}
assert(v != UNINITIALIZED_PTR);
i = PyLong_AS_LONG(v) + 1;
o = PyLong_FromLong(i);
- if (o == NULL)
- return -1;
+ if (o == NULL) {
+ goto error;
+ }
if (PyDict_SetItem(dict, k, o) < 0) {
Py_DECREF(o);
- return -1;
+ goto error;
}
Py_DECREF(o);
k = v = UNINITIALIZED_PTR;
} else {
return 0;
}
+error:
+ Py_DECREF(dict);
+ return -1;
}
descr.n_in_sequence = 1;
PyTypeObject* structseq_type = PyStructSequence_NewType(&descr);
- assert(structseq_type != NULL);
+ if (structseq_type == NULL) {
+ return NULL;
+ }
assert(PyType_Check(structseq_type));
assert(PyType_FastSubclass(structseq_type, Py_TPFLAGS_TUPLE_SUBCLASS));
Py_DECREF(structseq_type);