diff --git a/src/cpymad/madx.py b/src/cpymad/madx.py index 6b56723e..5382f173 100644 --- a/src/cpymad/madx.py +++ b/src/cpymad/madx.py @@ -196,7 +196,7 @@ def __init__(self, libmadx=None, command_log=None, stdout=None, if callable(stdout): try: stdout(b'') - except TypeError: + except (TypeError, ValueError): stdout = TextCallback(stdout) Popen_args['stdout'] = \ subprocess.PIPE if callable(stdout) else stdout