goto cleanup;
error:
+ assert(PyErr_Occurred());
Py_CLEAR(self);
cleanup:
if (file_obj != NULL) {
return obj_self;
error:
+ assert(PyErr_Occurred());
Py_XDECREF(file_repr);
Py_XDECREF(self);
return NULL;
self->trans_list_utc =
PyMem_Malloc(self->num_transitions * sizeof(int64_t));
if (self->trans_list_utc == NULL) {
+ PyErr_NoMemory();
goto error;
}
trans_idx = PyMem_Malloc(self->num_transitions * sizeof(Py_ssize_t));
if (trans_idx == NULL) {
+ PyErr_NoMemory();
goto error;
}
isdst = PyMem_Malloc(self->num_ttinfos * sizeof(unsigned char));
if (utcoff == NULL || isdst == NULL) {
+ PyErr_NoMemory();
goto error;
}
for (size_t i = 0; i < self->num_ttinfos; ++i) {
dstoff = PyMem_Calloc(self->num_ttinfos, sizeof(long));
if (dstoff == NULL) {
+ PyErr_NoMemory();
goto error;
}
// Build _ttinfo objects from utcoff, dstoff and abbr
self->_ttinfos = PyMem_Malloc(self->num_ttinfos * sizeof(_ttinfo));
if (self->_ttinfos == NULL) {
+ PyErr_NoMemory();
goto error;
}
for (size_t i = 0; i < self->num_ttinfos; ++i) {
self->trans_ttinfos =
PyMem_Calloc(self->num_transitions, sizeof(_ttinfo *));
if (self->trans_ttinfos == NULL) {
+ PyErr_NoMemory();
goto error;
}
for (size_t i = 0; i < self->num_transitions; ++i) {
p++;
if (parse_transition_rule(&p, transitions[i])) {
- PyErr_Format(PyExc_ValueError,
- "Malformed transition rule in TZ string: %R",
- tz_str_obj);
+ if (!PyErr_ExceptionMatches(PyExc_MemoryError)) {
+ PyErr_Format(PyExc_ValueError,
+ "Malformed transition rule in TZ string: %R",
+ tz_str_obj);
+ }
goto error;
}
}
CalendarRule *rv = PyMem_Calloc(1, sizeof(CalendarRule));
if (rv == NULL) {
+ PyErr_NoMemory();
return -1;
}
DayRule *rv = PyMem_Calloc(1, sizeof(DayRule));
if (rv == NULL) {
+ PyErr_NoMemory();
return -1;
}
for (size_t i = 0; i < 2; ++i) {
trans_local[i] = PyMem_Malloc(num_transitions * sizeof(int64_t));
if (trans_local[i] == NULL) {
+ PyErr_NoMemory();
return -1;
}