Skip to content

Commit

Permalink
rados.pyx: make all exceptions accept keyword arguments
Browse files Browse the repository at this point in the history
Moving the code that makes exceptions accept keyword arguments from the
exception OSError to Error prevents a crash when exceptions not
inheriting OSError are received.

Fixes: http://tracker.ceph.com/issues/24033
Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 1645802)
  • Loading branch information
rishabh-d-dave authored and smithfarm committed Jul 30, 2018
1 parent 5178d0a commit 88446f5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/pybind/rados/rados.pyx
Expand Up @@ -337,28 +337,26 @@ ADMIN_AUID = 0

class Error(Exception):
""" `Error` class, derived from `Exception` """
pass


class InvalidArgumentError(Error):
pass


class OSError(Error):
""" `OSError` class, derived from `Error` """
def __init__(self, message, errno=None):
super(OSError, self).__init__(message)
super(Exception, self).__init__(message)
self.errno = errno

def __str__(self):
msg = super(OSError, self).__str__()
msg = super(Exception, self).__str__()
if self.errno is None:
return msg
return '[errno {0}] {1}'.format(self.errno, msg)

def __reduce__(self):
return (self.__class__, (self.message, self.errno))

class InvalidArgumentError(Error):
pass

class OSError(Error):
""" `OSError` class, derived from `Error` """
pass

class InterruptedOrTimeoutError(OSError):
""" `InterruptedOrTimeoutError` class, derived from `OSError` """
pass
Expand Down

0 comments on commit 88446f5

Please sign in to comment.