File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1256,8 +1256,23 @@ def test_pickling(self):
1256
1256
pickled = pickle .dumps (oldpat , proto )
1257
1257
newpat = pickle .loads (pickled )
1258
1258
self .assertEqual (newpat , oldpat )
1259
- # previous pickles may expect the _compile() reconstructor in re module
1259
+
1260
+ def test_unpickling (self ):
1261
+ import pickle
1262
+ pat = re .compile (".*" )
1260
1263
from re import _compile # noqa: F401
1264
+ # previous pickles may expect the _compile() reconstructor in re module.
1265
+ # the four pickles below are examples of this at various protocol versions.
1266
+ pickles = [
1267
+ b'cre\n _compile\n p0\n (V.*\n p1\n I32\n tp2\n Rp3\n .' ,
1268
+ b'cre\n _compile\n q\x00 (X\x02 \x00 \x00 \x00 .*q\x01 K tq\x02 Rq\x03 .' ,
1269
+ b'\x80 \x03 cre\n _compile\n q\x00 X\x02 \x00 \x00 \x00 .*q\x01 K \x86 q\x02 Rq\x03 .' ,
1270
+ b'\x80 \x04 \x95 \x1e \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x8c \x02 re\x94 \x8c \x08 '
1271
+ b'_compile\x94 \x93 \x94 \x8c \x02 .*\x94 K \x86 \x94 R\x94 .' ,
1272
+ ]
1273
+ for pickled in pickles :
1274
+ unpickled = pickle .loads (pickled )
1275
+ self .assertEqual (unpickled , pat )
1261
1276
1262
1277
def test_copying (self ):
1263
1278
import copy
You can’t perform that action at this time.
0 commit comments