diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-19 17:40:55 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-23 16:58:20 +0100 |
commit | 45f536a701107c1c2c5c6acb22b62737f6b634b1 (patch) | |
tree | a159a00939c6dad2bfdda46344ffd08c9934084d /python | |
parent | 74feef4718770d20273aa97f9176484149f178ae (diff) | |
download | astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.tar.gz astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.tar.bz2 astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.tar.xz astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.zip |
Fix exception propagation in python dictToConfig
Diffstat (limited to 'python')
-rw-r--r-- | python/astra/utils.pxd | 2 | ||||
-rw-r--r-- | python/astra/utils.pyx | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/python/astra/utils.pxd b/python/astra/utils.pxd index e91ed98..ea3da86 100644 --- a/python/astra/utils.pxd +++ b/python/astra/utils.pxd @@ -32,4 +32,4 @@ from .PyXMLDocument cimport XMLNode from .PyIncludes cimport * cdef configToDict(Config *) -cdef Config * dictToConfig(string rootname, dc) +cdef Config * dictToConfig(string rootname, dc) except NULL diff --git a/python/astra/utils.pyx b/python/astra/utils.pyx index 46be462..b534d72 100644 --- a/python/astra/utils.pyx +++ b/python/astra/utils.pyx @@ -26,6 +26,7 @@ # distutils: language = c++ # distutils: libraries = astra +import sys cimport numpy as np import numpy as np import six @@ -45,15 +46,15 @@ from .PyXMLDocument cimport XMLNode from .PyIncludes cimport * -cdef Config * dictToConfig(string rootname, dc): +cdef Config * dictToConfig(string rootname, dc) except NULL: cdef Config * cfg = new Config() cfg.initialize(rootname) try: readDict(cfg.self, dc) - except Exception as e: + except Exception: del cfg - six.print_(e.strerror) - return NULL + exc = sys.exc_info() + raise exc[0], exc[1], exc[2] return cfg def convert_item(item): @@ -85,7 +86,7 @@ def wrap_from_bytes(value): return s -cdef void readDict(XMLNode root, _dc): +cdef bool readDict(XMLNode root, _dc) except False: cdef XMLNode listbase cdef XMLNode itm cdef int i @@ -122,8 +123,9 @@ cdef void readDict(XMLNode root, _dc): if isinstance(val, builtins.bool): val = int(val) itm = root.addChildNode(item, wrap_to_bytes(val)) + return True -cdef void readOptions(XMLNode node, dc): +cdef bool readOptions(XMLNode node, dc) except False: cdef XMLNode listbase cdef XMLNode itm cdef int i @@ -152,6 +154,7 @@ cdef void readOptions(XMLNode node, dc): if isinstance(val, builtins.bool): val = int(val) node.addOption(item, wrap_to_bytes(val)) + return True cdef configToDict(Config *cfg): return XMLNode2dict(cfg.self) |