Skip to content

bpo-44630: Fix assertion errors in csv module#27127

Merged
gpshead merged 2 commits intopython:mainfrom
Yhg1s:csv_assertion_failure
Jul 13, 2021
Merged

bpo-44630: Fix assertion errors in csv module#27127
gpshead merged 2 commits intopython:mainfrom
Yhg1s:csv_assertion_failure

Conversation

@Yhg1s
Copy link
Copy Markdown
Member

@Yhg1s Yhg1s commented Jul 13, 2021

Fix assertion errors in the csv module, when passing None as the 'dialect' argument. The csv module not clearing exceptions between calls to PyObject_GetAttrString() causes assertion failures in pydebug mode (or with assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or any object that isn't a csv.Dialect subclass, which the csv module allows and caters to, even though it is not documented.) In pydebug mode, the test triggers the assertion failure in the old code.

https://bugs.python.org/issue44630

…s in

the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.
@gpshead gpshead self-assigned this Jul 13, 2021
@gpshead gpshead added the type-bug An unexpected behavior, bug, or error label Jul 13, 2021
@gpshead gpshead merged commit 0093876 into python:main Jul 13, 2021
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @Yhg1s for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9.
🐍🍒⛏🤖

@bedevere-bot
Copy link
Copy Markdown

GH-27129 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 13, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 13, 2021
Fix incorrect handling of exceptions when interpreting dialect objects in
the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.

Contributed-By: T. Wouters [Google]
(cherry picked from commit 0093876)

Co-authored-by: T. Wouters <[email protected]>
@bedevere-bot
Copy link
Copy Markdown

GH-27130 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 13, 2021
Fix incorrect handling of exceptions when interpreting dialect objects in
the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.

Contributed-By: T. Wouters [Google]
(cherry picked from commit 0093876)

Co-authored-by: T. Wouters <[email protected]>
miss-islington added a commit that referenced this pull request Jul 13, 2021
…7129)

Fix incorrect handling of exceptions when interpreting dialect objects in
the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.

Contributed-By: T. Wouters [Google]
(cherry picked from commit 0093876)


Co-authored-by: T. Wouters <[email protected]>

Automerge-Triggered-By: GH:gpshead
miss-islington added a commit that referenced this pull request Jul 13, 2021
Fix incorrect handling of exceptions when interpreting dialect objects in
the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.

Contributed-By: T. Wouters [Google]
(cherry picked from commit 0093876)

Co-authored-by: T. Wouters <[email protected]>
@Yhg1s Yhg1s deleted the csv_assertion_failure branch October 21, 2022 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants