]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-44630: Fix assertion errors in csv module (GH-27127)
authorT. Wouters <thomas@python.org>
Tue, 13 Jul 2021 22:56:45 +0000 (00:56 +0200)
committerGitHub <noreply@github.com>
Tue, 13 Jul 2021 22:56:45 +0000 (15:56 -0700)
commit0093876328afa330224c9d887c18dee0b3117852
tree9bd8a30bb6577ab1a973fa68b078ee5e6627f873
parent054e9c84ac7c394941bba3ea1829d14dce1243fc
bpo-44630: Fix assertion errors in csv module (GH-27127)

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]
Lib/test/test_csv.py
Modules/_csv.c