summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-04-06 13:11:07 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-04-06 13:11:07 +0000
commitcb1573c61cb5f077a35fb8ea15cbfd7287918e73 (patch)
tree9bb510e5acc523733dc27f86d093945df01cc575 /bindings
parent512f951b8b5c50c5bc2f6380c2a0b9307f33aaed (diff)
downloadlasso-cb1573c61cb5f077a35fb8ea15cbfd7287918e73.tar.gz
lasso-cb1573c61cb5f077a35fb8ea15cbfd7287918e73.tar.xz
lasso-cb1573c61cb5f077a35fb8ea15cbfd7287918e73.zip
Binding python: fix use of raise_on_rc, simplift Node.__setstate__
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/lang.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/bindings/python/lang.py b/bindings/python/lang.py
index 0a9c3b1c..54d6812f 100644
--- a/bindings/python/lang.py
+++ b/bindings/python/lang.py
@@ -164,9 +164,10 @@ class Error(Exception):
@staticmethod
def raise_on_rc(rc):
global exceptions_dict
- exception = exceptions_dict.get(rc, Error())
- exception.code = rc
- raise exception
+ if rc != 0:
+ exception = exceptions_dict.get(rc, Error())
+ exception.code = rc
+ raise exception
def __str__(self):
return '<lasso.%s(%s): %s>' % (self.__class__.__name__, self.code, _lasso.strError(self.code))
@@ -264,8 +265,7 @@ def LassoNode__getstate__(self):
return { '__dump__': self.dump() }
def LassoNode__setstate__(self, d):
- dump = d['__dump__']
- self._cptr = _lasso.node_new_from_dump(dump)
+ self._cptr = _lasso.node_new_from_dump(d.pop('__dump__'))
Node.__getstate__ = LassoNode__getstate__
Node.__setstate__ = LassoNode__setstate__
@@ -504,8 +504,7 @@ if WSF_SUPPORT:
elif is_rc(m.return_arg):
print >> fd, ' rc = _lasso.%s(self._cptr%s)' % (
function_name, c_args)
- print >> fd, ' if rc != 0:'
- print >> fd, ' raise Error.raise_on_rc(rc)'
+ print >> fd, ' Error.raise_on_rc(rc)'
elif is_int(m.return_arg, self.binding_data) or is_xml_node(m.return_arg) or is_cstring(m.return_arg) or is_boolean(m.return_arg):
print >> fd, ' return _lasso.%s(self._cptr%s)' % (
function_name, c_args)