python: do not fail displaying a non-C error (fixes #3866)

The binding does a raise Error('failed to create object') but the local Error
exception class expects a lasso error code, and will thus fail if printed.

  File ".../lasso.py", line 54, in __str__
    return '<lasso.%s(%s): %s>' % (self.__class__.__name__, self.code,
             _lasso.strError(self.code))
  TypeError: an integer is required
This commit is contained in:
Frédéric Péters 2013-10-23 15:31:23 +02:00 committed by Benjamin Dauvergne
parent e50981372f
commit 080548538d
1 changed files with 4 additions and 1 deletions

View File

@ -168,7 +168,10 @@ class Error(Exception):
raise exception
def __str__(self):
return '<lasso.%s(%s): %s>' % (self.__class__.__name__, self.code, _lasso.strError(self.code))
if self.code:
return '<lasso.%s(%s): %s>' % (self.__class__.__name__, self.code, _lasso.strError(self.code))
else:
return '<lasso.%s: %s>' % (self.__class__.__name__, self.message)
def __getitem__(self, i):
# compatibility with SWIG bindings