GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Handle errors correctly in `tmtotuple` in `timemodule` · Issue #118998 · python/cpython

Handle errors correctly in tmtotuple in timemodule #118998

New issue
Copy link
New issue
Copy link
Closed
Closed
Handle errors correctly in tmtotuple in timemodule#118998
Copy link
Assignees
sobolevn
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on May 13, 2024
Issue body actions

Bug report

This call is problematic:

cpython/Modules/timemodule.c

Line 465 in f526314

#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:

  • cpython/Modules/timemodule.c

    Lines 477 to 478 in f526314

    PyStructSequence_SET_ITEM(v, 9,
    PyUnicode_DecodeLocale(p->tm_zone, "surrogateescape"));
  • cpython/Modules/timemodule.c

    Lines 481 to 482 in f526314

    PyStructSequence_SET_ITEM(v, 9,
    PyUnicode_DecodeLocale(zone, "surrogateescape"));

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

cpython/Modules/timemodule.c

Lines 486 to 489 in f526314

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

  • gh-118998: Handle errors correctly in tmtotuple in timemodule #118999
  • [3.13] gh-118998: Handle errors correctly in tmtotuple in timemodule (GH-118999) #119018
  • [3.12] gh-118998: Handle errors correctly in tmtotuple in timemodule (GH-118999) #119019

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on May 13, 2024
  2. sobolevn
    self-assigned this
    on May 13, 2024
  3. sobolevn
    added 3 commits that reference this issue on May 13, 2024

    pythongh-118998: Handle errors correctly in `tmtotuple` in `timemodule`

    e312e3c

    pythongh-118998: Handle errors correctly in `tmtotuple` in `timemodule`

    8360ca5

    gh-118998: Handle errors correctly in `tmtotuple` in `timemodule` (#1…

    fc75792
  4. miss-islington
    added 2 commits that reference this issue on May 13, 2024

    pythongh-118998: Handle errors correctly in `tmtotuple` in `timemodul…

    298a8f8

    pythongh-118998: Handle errors correctly in `tmtotuple` in `timemodul…

    ae5874b
  5. sobolevn
    added 2 commits that reference this issue on May 13, 2024

    [3.13] gh-118998: Handle errors correctly in `tmtotuple` in `timemodu…

    c7628b0

    [3.12] gh-118998: Handle errors correctly in `tmtotuple` in `timemodu…

    5bf7f5c
  6. sobolevn
    closed this as completedon May 13, 2024
  7. estyxx
    added a commit that references this issue on Jul 17, 2024

    pythongh-118998: Handle errors correctly in `tmtotuple` in `timemodul…

    652ac81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

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

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.