classification
Title: Assertion failure in csv module
Type: crash Stage: commit review
Components: Extension Modules Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: twouters Nosy List: gregory.p.smith, miss-islington, twouters
Priority: normal Keywords: patch

Created on 2021-07-13 21:49 by twouters, last changed 2021-07-13 23:26 by gregory.p.smith. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27127 merged twouters, 2021-07-13 21:56
PR 27129 merged miss-islington, 2021-07-13 22:56
PR 27130 merged miss-islington, 2021-07-13 22:57
Messages (5)
msg397446 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2021-07-13 21:49
The csv module has some incorrect exception handling when dealing with dialect objects that are not csv.Dialect subclasses (or that otherwise raise errors when accessing the dialect attributes):

>>> csv.reader([], dialect=None)
python: ../../cpython/Objects/typeobject.c:3820: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.
Aborted

The problem is Modules/_csv.c tries to cater to dialects that lack the attributes it wants to access, but does so by leaving exceptions set between calls to PyObject_SetAttrString(). Since 3.7, that causes assertion failures. (I have a PR with a fix.)
msg397451 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-07-13 22:56
New changeset 0093876328afa330224c9d887c18dee0b3117852 by T. Wouters in branch 'main':
bpo-44630: Fix assertion errors in csv module (GH-27127)
https://github.com/python/cpython/commit/0093876328afa330224c9d887c18dee0b3117852
msg397452 - (view) Author: miss-islington (miss-islington) Date: 2021-07-13 23:18
New changeset bb260c2a212aee2a7d7a32bf5208fd554bf72713 by Miss Islington (bot) in branch '3.10':
[3.10] bpo-44630: Fix assertion errors in csv module (GH-27127) (GH-27129)
https://github.com/python/cpython/commit/bb260c2a212aee2a7d7a32bf5208fd554bf72713
msg397453 - (view) Author: miss-islington (miss-islington) Date: 2021-07-13 23:20
New changeset fe73509c5ba3844b45a2253967522531ab80c849 by Miss Islington (bot) in branch '3.9':
bpo-44630: Fix assertion errors in csv module (GH-27127)
https://github.com/python/cpython/commit/fe73509c5ba3844b45a2253967522531ab80c849
msg397454 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-07-13 23:26
Thanks!

Things like this both internal to CPython and in CPython API misuse in all sorts of third party extension modules are why i think we as a project really should to encourage more CI systems to have -UNDEBUG builds of CPython available and in use by default when people request Python...

To answer anyone's "why no news entry?" questions... This only shows up in -UNDEBUG (and thus pydebug) builds of CPython.  Which basically nobody uses.

We, Google, keep C assertions enabled by undefining NDEBUG in our default non-release builds that everything by default runs tests against as a way to help improve code quality.
History
Date User Action Args
2021-09-11 10:44:37iritkatriellinkissue38942 superseder
2021-07-13 23:26:06gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg397454

stage: patch review -> commit review
2021-07-13 23:20:32miss-islingtonsetmessages: + msg397453
2021-07-13 23:18:36miss-islingtonsetmessages: + msg397452
2021-07-13 22:57:02miss-islingtonsetpull_requests: + pull_request25673
2021-07-13 22:56:56miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25672
2021-07-13 22:56:52gregory.p.smithsetmessages: + msg397451
2021-07-13 21:56:45twouterssetkeywords: + patch
stage: patch review
pull_requests: + pull_request25670
2021-07-13 21:49:13twouterscreate