Visitar URL original
Handle errors correctly in `tmtotuple` in `timemodule` · Issue #118998 · python/cpython · GitHub
Skip to content

Handle errors correctly in tmtotuple in timemodule #118998

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

Activity

  1. self-assigned this
    on May 13, 2024
  2. added 3 commits that reference this issue on May 13, 2024
  3. added 2 commits that reference this issue on May 13, 2024
  4. added 2 commits that reference this issue on May 13, 2024
  5. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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