File tree 3 files changed +14
-3
lines changed
Filter options
3 files changed +14
-3
lines changed
Original file line number Diff line number Diff line change 10
10
import gc
11
11
import pickle
12
12
from test import support
13
- from test .support import warnings_helper
13
+ from test .support import warnings_helper , import_helper , check_disallow_instantiation
14
14
from itertools import permutations
15
15
from textwrap import dedent
16
16
from collections import OrderedDict
@@ -1390,5 +1390,12 @@ def test_subclassable(self):
1390
1390
# issue 44089
1391
1391
class Foo (csv .Error ): ...
1392
1392
1393
+ @support .cpython_only
1394
+ def test_disallow_instantiation (self ):
1395
+ _csv = import_helper .import_module ("_csv" )
1396
+ for tp in _csv .Reader , _csv .Writer :
1397
+ with self .subTest (tp = tp ):
1398
+ check_disallow_instantiation (self , tp )
1399
+
1393
1400
if __name__ == '__main__' :
1394
1401
unittest .main ()
Original file line number Diff line number Diff line change
1
+ Prevent possible crash by disallowing instantiation of the
2
+ :class: `!_csv.Reader ` and :class: `!_csv.Writer ` types.
3
+ The regression was introduced in 3.10.0a4 with PR 23224 (:issue: `14935 `).
4
+ Patch by Radislav Chugunov.
Original file line number Diff line number Diff line change @@ -1000,7 +1000,7 @@ PyType_Spec Reader_Type_spec = {
1000
1000
.name = "_csv.reader" ,
1001
1001
.basicsize = sizeof (ReaderObj ),
1002
1002
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1003
- Py_TPFLAGS_IMMUTABLETYPE ),
1003
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION ),
1004
1004
.slots = Reader_Type_slots
1005
1005
};
1006
1006
@@ -1425,7 +1425,7 @@ PyType_Spec Writer_Type_spec = {
1425
1425
.name = "_csv.writer" ,
1426
1426
.basicsize = sizeof (WriterObj ),
1427
1427
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1428
- Py_TPFLAGS_IMMUTABLETYPE ),
1428
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION ),
1429
1429
.slots = Writer_Type_slots ,
1430
1430
};
1431
1431
You can’t perform that action at this time.
0 commit comments