Repository navigation
Improve stdlib module initialization error handling. #83004
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/brandtbucher'
closed_at = None
created_at = <Date 2019-11-16.18:54:25.878>
labels = ['3.7', '3.8', 'type-bug', 'library', '3.9']
title = 'Improve stdlib module initialization error handling.'
updated_at = <Date 2020-11-13.13:44:17.121>
user = 'https://github.com/brandtbucher'bugs.python.org fields:
activity = <Date 2020-11-13.13:44:17.121>
actor = 'vstinner'
assignee = 'brandtbucher'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2019-11-16.18:54:25.878>
creator = 'brandtbucher'
dependencies = []
files = []
hgrepos = []
issue_num = 38823
keywords = ['patch']
message_count = 30.0
messages = ['356764', '356765', '356773', '356774', '356775', '356781', '356782', '356783', '356809', '356820', '356872', '356873', '356874', '356984', '357002', '357003', '357004', '357014', '357019', '357029', '357044', '357046', '357047', '357050', '357051', '357114', '361486', '380822', '380824', '380883']
nosy_count = 8.0
nosy_names = ['twouters', 'vstinner', 'asvetlov', 'serhiy.storchaka', 'miss-islington', 'brandtbucher', 'shihai1991', 'erlendaasland']
pr_nums = ['17195', '17196', '17197', '17198', '17199', '17200', '17206', '17215', '17216', '17226', '17227', '17235', '17236', '17250', '17260', '17263', '17264', '17271', '17272', '17276', '17280', '17281', '17282', '17283', '17298', '18365', '23247', '23248', '23258']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue38823'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
brandtbucher commentedon Nov 16, 2019
Many of the C stdlib modules can benefit from improved error handling during initialization. I've now had two PRs where the authors had reference leaks on error conditions, but defended their decisions by pointing to examples of similar idioms all over the stdlib.
The problems fall into two related categories, mostly:
I intend to turn this into a longer term project. I'll be working my way through these modules bit-by-bit over time, using this issue to track all of them (since there are a few dozen cases). I'd rather not make one huge one that spams all of the code owners and is impossible to review.
If anybody want to make themselves available to review/merge these as I go along, that would be great! Many of the ones I'll start with are just adding trivial DECREFs to the more popular modules (_asyncio, _contextvars, _functools, _random, _warnings, etc...).
brandtbucher commentedon Nov 16, 2019
How do others feel about the creation of a new private API? It would keep these diffs smaller and ease refactoring... and it would probably be good to have around anyways:
/* Like PyModule_AddObject, but steals o on success AND failure. */
miss-islington commentedon Nov 16, 2019
New changeset c3f6bdc by Miss Islington (bot) (Brandt Bucher) in branch 'master':
bpo-38823: Clean up refleaks in _asyncio initialization. (GH-17195)
c3f6bdc
miss-islington commentedon Nov 16, 2019
New changeset 48f4f75 by Miss Islington (bot) in branch '3.8':
bpo-38823: Clean up refleaks in _asyncio initialization. (GH-17195)
48f4f75
miss-islington commentedon Nov 16, 2019
New changeset 825e91b by Miss Islington (bot) in branch '3.7':
bpo-38823: Clean up refleaks in _asyncio initialization. (GH-17195)
825e91b
miss-islington commentedon Nov 16, 2019
New changeset 143a97f by Miss Islington (bot) (Brandt Bucher) in branch 'master':
bpo-38823: Clean up refleaks in _contextvars initialization. (GH-17198)
143a97f
miss-islington commentedon Nov 17, 2019
New changeset 8a334af by Miss Islington (bot) in branch '3.7':
bpo-38823: Clean up refleaks in _contextvars initialization. (GH-17198)
8a334af
miss-islington commentedon Nov 17, 2019
New changeset 1fe79a4 by Miss Islington (bot) in branch '3.8':
bpo-38823: Clean up refleaks in _contextvars initialization. (GH-17198)
1fe79a4
asvetlov commentedon Nov 17, 2019
Is anything left to be done for the issue?
62 remaining items
pythongh-83004: Harden msvcrt further
gh-83004: Harden winreg init (#103386)
pythongh-83004: Harden _socket init (pythonGH-103261)
pythongh-83004: Harden winsound init (python#103385)
pythongh-83004: Harden `msvcrt` init (python#103383)
pythongh-83004: Harden winreg init (python#103386)
pythongh-83004: Harden winsound init (python#103385)
pythongh-83004: Harden `msvcrt` init (python#103383)
pythongh-83004: Harden winreg init (python#103386)
gh-83004: Harden msvcrt further (#103420)
Merge branch 'main' into superopt
erlend-aasland commentedon Feb 8, 2024
A lot of issues were fixed by Serhiy in #106858. Are there more actionable items left? (I did not check the
_decimalPR yet.)vstinner commentedon Feb 8, 2024
I suggest to close the issue which has a long history, and maybe create a new issue with a better described scope (list C extensions) if more C extensions need to be fixed.
erlend-aasland commentedon Feb 9, 2024
All right, there are no open PRs left (they were all obsoleted by Serhiy's recent work in #106858).
I agree; let's close this :) Thanks to Brandt for starting this effort in the first place, and thanks to all who improved extension module error handling!