Skip to content

Commit 2b458c1

Browse files
bpo-44089: Allow subclassing of csv.Error (GH-26008)
* fix subclass error * Update 2021-05-09-22-52-34.bpo-44089.IoANsN.rst
1 parent 5010c04 commit 2b458c1

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Lib/test/test_csv.py

+3
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,9 @@ def test__all__(self):
12371237
extra = {'__doc__', '__version__'}
12381238
support.check__all__(self, csv, ('csv', '_csv'), extra=extra)
12391239

1240+
def test_subclassable(self):
1241+
# issue 44089
1242+
class Foo(csv.Error): ...
12401243

12411244
if __name__ == '__main__':
12421245
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Allow subclassing ``csv.Error`` in 3.10 (it was allowed in 3.9 and earlier but
2+
was disallowed in early versions of 3.10).

Modules/_csv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ static PyType_Slot error_slots[] = {
15151515

15161516
PyType_Spec error_spec = {
15171517
.name = "_csv.Error",
1518-
.flags = Py_TPFLAGS_DEFAULT,
1518+
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
15191519
.slots = error_slots,
15201520
};
15211521

0 commit comments

Comments
 (0)