Skip to content

Handle errors correctly in tmtotuple in timemodule #118998

Closed
@sobolevn

Description

@sobolevn

Bug report

This call is problematic:

#define SET(i,val) PyStructSequence_SET_ITEM(v, i, PyLong_FromLong((long) val))

It can return NULL in theory.

These calls also can return NULL:

This error guard in the end will only show the last error:

if (PyErr_Occurred()) {
Py_XDECREF(v);
return NULL;
}
Not the first one. Also: why XDECREF when v cannot be NULL at this point?

Refs #116714

I will send a PR adding our regular macro for the job.

Linked PRs

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions