Skip to content

bpo-27015: Save kwargs given to exceptions constructor #11580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move CalledProcessError pickling test to test_subprocess
  • Loading branch information
Rémi Lapeyre committed Jan 16, 2019
commit 1d12d28ffa2dfb7c41ba5cd3d8e98838e9bdbb44
8 changes: 2 additions & 6 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,14 +1415,10 @@ def test_copy_pickle(self):

def test_pickle_overriden_init(self):
# Issue #27015
from subprocess import CalledProcessError

for proto in range(pickle.HIGHEST_PROTOCOL + 1):
orig = CalledProcessError(returncode=2, cmd='foo')
orig = NaiveException(x='foo')
exc = pickle.loads(pickle.dumps(orig, proto))
self.assertEqual(orig.cmd, exc.cmd)
self.assertEqual(orig.returncode, exc.returncode)

self.assertEqual(orig.x, exc.x)


if __name__ == '__main__':
Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import threading
import gc
import textwrap
import pickle
from test.support import FakePath

try:
Expand Down Expand Up @@ -1690,6 +1691,14 @@ def test_CalledProcessError_str_non_zero(self):
error_string = str(err)
self.assertIn("non-zero exit status 2.", error_string)

def test_CalledProcessError_picklable(self):
# Issue #27015
err = subprocess.CalledProcessError(returncode=2, cmd='foo')
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
new = pickle.loads(pickle.dumps(err, proto))
self.assertEqual(err.returncode, new.returncode)
self.assertEqual(err.cmd, new.cmd)

def test_preexec(self):
# DISCLAIMER: Setting environment variables is *not* a good use
# of a preexec_fn. This is merely a test.
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy