Issue #22995: Instances of extension types with a state that aren't
subclasses of list or dict and haven't implemented any pickle-related
methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__,
or __getstate__), can no longer be pickled. Including memoryview.
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index e2eec70..181af99 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -2,6 +2,7 @@
# Copyright (C) 2001,2002 Python Software Foundation
# csv package unit tests
+import copy
import sys
import os
import unittest
@@ -10,6 +11,7 @@
import csv
import gc
import io
+import pickle
from test import test_support
class Test_Csv(unittest.TestCase):
@@ -466,6 +468,17 @@
self.assertRaises(TypeError, csv.reader, [], quoting = -1)
self.assertRaises(TypeError, csv.reader, [], quoting = 100)
+ def test_copy(self):
+ for name in csv.list_dialects():
+ dialect = csv.get_dialect(name)
+ self.assertRaises(TypeError, copy.copy, dialect)
+
+ def test_pickle(self):
+ for name in csv.list_dialects():
+ dialect = csv.get_dialect(name)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ self.assertRaises(TypeError, pickle.dumps, dialect, proto)
+
class TestCsvBase(unittest.TestCase):
def readerAssertEqual(self, input, expected_result):
fd, name = tempfile.mkstemp()