New submission from Taywee:

When using kwargs to construct a CalledProcessError, the repr doesn't show 
those args, and using kwargs also breaks pickling:

>>> import pickle; from subprocess import CalledProcessError
>>> CalledProcessError(2, 'foo')
CalledProcessError(2, 'foo')
>>> CalledProcessError(2, 'foo').returncode
2
>>> CalledProcessError(2, 'foo').cmd
'foo'
>>> CalledProcessError(returncode=2, cmd='foo')
CalledProcessError()
>>> CalledProcessError(returncode=2, cmd='foo').returncode
2
>>> CalledProcessError(returncode=2, cmd='foo').cmd
'foo'
>>> pickle.loads(pickle.dumps(CalledProcessError(2, 'foo')))
CalledProcessError(2, 'foo')
>>> pickle.loads(pickle.dumps(CalledProcessError(returncode=2, cmd='foo')))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() missing 2 required positional arguments: 'returncode' and 
'cmd'
>>>

----------
components: Library (Lib)
messages: 265482
nosy: Taywee
priority: normal
severity: normal
status: open
title: subprocess.CalledProcessError's repr changes based on kwargs, and 
doesn't unpickle
type: behavior
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27015>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to