Added self.args for exception classes. Used for unpickling

Related to fabric/fabric#986 and fabric/fabric#714

Conflicts:
	sites/www/changelog.rst
This commit is contained in:
Jeff Forcier 2014-04-16 15:51:01 -04:00
parent 6e9abc39cf
commit 30f6f98afd
2 changed files with 15 additions and 1 deletions

View File

@ -59,6 +59,8 @@ class BadAuthenticationType (AuthenticationException):
def __init__(self, explanation, types): def __init__(self, explanation, types):
AuthenticationException.__init__(self, explanation) AuthenticationException.__init__(self, explanation)
self.allowed_types = types self.allowed_types = types
# for unpickling
self.args = (explanation, types, )
def __str__(self): def __str__(self):
return SSHException.__str__(self) + ' (allowed_types=%r)' % self.allowed_types return SSHException.__str__(self) + ' (allowed_types=%r)' % self.allowed_types
@ -73,6 +75,8 @@ class PartialAuthentication (AuthenticationException):
def __init__(self, types): def __init__(self, types):
AuthenticationException.__init__(self, 'partial authentication') AuthenticationException.__init__(self, 'partial authentication')
self.allowed_types = types self.allowed_types = types
# for unpickling
self.args = (types, )
class ChannelException (SSHException): class ChannelException (SSHException):
@ -86,6 +90,8 @@ class ChannelException (SSHException):
def __init__(self, code, text): def __init__(self, code, text):
SSHException.__init__(self, text) SSHException.__init__(self, text)
self.code = code self.code = code
# for unpickling
self.args = (code, text, )
class BadHostKeyException (SSHException): class BadHostKeyException (SSHException):
@ -103,6 +109,8 @@ class BadHostKeyException (SSHException):
self.hostname = hostname self.hostname = hostname
self.key = got_key self.key = got_key
self.expected_key = expected_key self.expected_key = expected_key
# for unpickling
self.args = (hostname, got_key, expected_key, )
class ProxyCommandFailure (SSHException): class ProxyCommandFailure (SSHException):
@ -119,3 +127,5 @@ class ProxyCommandFailure (SSHException):
) )
) )
self.error = error self.error = error
# for unpickling
self.args = (command, error, )

View File

@ -2,6 +2,10 @@
Changelog Changelog
========= =========
* :bug:`-` Added self.args for exception classes. Used for unpickling. Related
to (`Fabric #986 <https://github.com/fabric/fabric/issues/986>`_, `Fabric
#714 <https://github.com/fabric/fabric/issues/714>`_). Thanks to Alex
Plugaru.
* :bug:`-` Fix logging error in sftp_client for filenames containing the '%' * :bug:`-` Fix logging error in sftp_client for filenames containing the '%'
character. Thanks to Antoine Brenner. character. Thanks to Antoine Brenner.
* :support:`284` Add Python language trove identifiers to ``setup.py``. Thanks * :support:`284` Add Python language trove identifiers to ``setup.py``. Thanks