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
@@ -1430,5 +1430,12 @@ def test_subclassable(self):
1430
1430
# issue 44089
1431
1431
class Foo (csv .Error ): ...
1432
1432
1433
+ @support .cpython_only
1434
+ def test_disallow_instantiation (self ):
1435
+ _csv = import_helper .import_module ("_csv" )
1436
+ for tp in _csv .Reader , _csv .Writer :
1437
+ with self .subTest (tp = tp ):
1438
+ check_disallow_instantiation (self , tp )
1439
+
1433
1440
if __name__ == '__main__' :
1434
1441
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
@@ -1431,7 +1431,7 @@ PyType_Spec Writer_Type_spec = {
1431
1431
.name = "_csv.writer" ,
1432
1432
.basicsize = sizeof (WriterObj ),
1433
1433
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1434
- Py_TPFLAGS_IMMUTABLETYPE ),
1434
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION ),
1435
1435
.slots = Writer_Type_slots ,
1436
1436
};
1437
1437
You can’t perform that action at this time.
0 commit comments