File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1415,14 +1415,10 @@ def test_copy_pickle(self):
1415
1415
1416
1416
def test_pickle_overriden_init (self ):
1417
1417
# Issue #27015
1418
- from subprocess import CalledProcessError
1419
-
1420
1418
for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
1421
- orig = CalledProcessError ( returncode = 2 , cmd = 'foo' )
1419
+ orig = NaiveException ( x = 'foo' )
1422
1420
exc = pickle .loads (pickle .dumps (orig , proto ))
1423
- self .assertEqual (orig .cmd , exc .cmd )
1424
- self .assertEqual (orig .returncode , exc .returncode )
1425
-
1421
+ self .assertEqual (orig .x , exc .x )
1426
1422
1427
1423
1428
1424
if __name__ == '__main__' :
Original file line number Diff line number Diff line change 18
18
import threading
19
19
import gc
20
20
import textwrap
21
+ import pickle
21
22
from test .support import FakePath
22
23
23
24
try :
@@ -1690,6 +1691,14 @@ def test_CalledProcessError_str_non_zero(self):
1690
1691
error_string = str (err )
1691
1692
self .assertIn ("non-zero exit status 2." , error_string )
1692
1693
1694
+ def test_CalledProcessError_picklable (self ):
1695
+ # Issue #27015
1696
+ err = subprocess .CalledProcessError (returncode = 2 , cmd = 'foo' )
1697
+ for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
1698
+ new = pickle .loads (pickle .dumps (err , proto ))
1699
+ self .assertEqual (err .returncode , new .returncode )
1700
+ self .assertEqual (err .cmd , new .cmd )
1701
+
1693
1702
def test_preexec (self ):
1694
1703
# DISCLAIMER: Setting environment variables is *not* a good use
1695
1704
# of a preexec_fn. This is merely a test.
You can’t perform that action at this time.
0 commit comments