diff --git a/eventlet/green/subprocess.py b/eventlet/green/subprocess.py index d639cd5..96adff5 100644 --- a/eventlet/green/subprocess.py +++ b/eventlet/green/subprocess.py @@ -133,3 +133,7 @@ if hasattr(subprocess_orig, 'check_output'): __patched__.append('check_output') check_output = patched_function(subprocess_orig.check_output) del patched_function + +# Keep exceptions identity. +# https://github.com/eventlet/eventlet/issues/413 +CalledProcessError = subprocess_orig.CalledProcessError diff --git a/tests/subprocess_test.py b/tests/subprocess_test.py index d18c623..572d386 100644 --- a/tests/subprocess_test.py +++ b/tests/subprocess_test.py @@ -93,3 +93,13 @@ def test_check_call_without_timeout_works(): stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) + + +def test_exception_identity(): + # https://github.com/eventlet/eventlet/issues/413 + # green module must keep exceptions classes as stdlib version + cases = ( + 'CalledProcessError', + ) + for c in cases: + assert getattr(subprocess, c) is getattr(original_subprocess, c), c