Skip to content

gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed#146113

Merged
vstinner merged 1 commit intopython:mainfrom
vstinner:fix_csv
Mar 18, 2026
Merged

gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed#146113
vstinner merged 1 commit intopython:mainfrom
vstinner:fix_csv

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 18, 2026

The function can fail on a memory allocation failure.

Bug reported by devdanzin.

… failed

The function can fail on a memory allocation failure.

Bug reported by devdanzin.
@vstinner
Copy link
Member Author

Writing a test requires using _testcapi.set_nomemory() with a precise number of allocations. It's hard to write a reliable test for that. So I skipped the test instead.

@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label Mar 18, 2026
@serhiy-storchaka
Copy link
Member

It can also fail for non-ASCII data, isn't?

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the default is hardcoded ASCII string. LGTM. 👍

@vstinner vstinner merged commit 724c7c8 into python:main Mar 18, 2026
59 checks passed
@vstinner vstinner deleted the fix_csv branch March 18, 2026 17:20
@miss-islington-app
Copy link

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 18, 2026
… failed (pythonGH-146113)

The function can fail on a memory allocation failure.

Bug reported by devdanzin.
(cherry picked from commit 724c7c8)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Mar 18, 2026

GH-146130 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Mar 18, 2026
@vstinner vstinner added the needs backport to 3.13 bugs and security fixes label Mar 18, 2026
@miss-islington-app
Copy link

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 18, 2026
… failed (pythonGH-146113)

The function can fail on a memory allocation failure.

Bug reported by devdanzin.
(cherry picked from commit 724c7c8)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Mar 18, 2026

GH-146131 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 18, 2026
@vstinner
Copy link
Member Author

Merged. Thanks for your review @serhiy-storchaka.

vstinner added a commit that referenced this pull request Mar 18, 2026
…) failed (GH-146113) (#146131)

gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed (GH-146113)

The function can fail on a memory allocation failure.

Bug reported by devdanzin.
(cherry picked from commit 724c7c8)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Mar 18, 2026
…) failed (GH-146113) (#146130)

gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed (GH-146113)

The function can fail on a memory allocation failure.

Bug reported by devdanzin.
(cherry picked from commit 724c7c8)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants