Skip to content

Commit

Permalink
bpo-44089: Allow subclassing of csv.Error (GH-26008) (GH-26066)
Browse files Browse the repository at this point in the history
* fix subclass error

* Update 2021-05-09-22-52-34.bpo-44089.IoANsN.rst
(cherry picked from commit 2b458c1)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
  • Loading branch information
miss-islington and Fidget-Spinner committed May 12, 2021
1 parent 48cb11b commit 3e44e9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Lib/test/test_csv.py
Expand Up @@ -1237,6 +1237,9 @@ def test__all__(self):
extra = {'__doc__', '__version__'}
support.check__all__(self, csv, ('csv', '_csv'), extra=extra)

def test_subclassable(self):
# issue 44089
class Foo(csv.Error): ...

if __name__ == '__main__':
unittest.main()
@@ -0,0 +1,2 @@
Allow subclassing ``csv.Error`` in 3.10 (it was allowed in 3.9 and earlier but
was disallowed in early versions of 3.10).
2 changes: 1 addition & 1 deletion Modules/_csv.c
Expand Up @@ -1515,7 +1515,7 @@ static PyType_Slot error_slots[] = {

PyType_Spec error_spec = {
.name = "_csv.Error",
.flags = Py_TPFLAGS_DEFAULT,
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.slots = error_slots,
};

Expand Down

0 comments on commit 3e44e9a

Please sign in to comment.