summaryrefslogtreecommitdiffstats
path: root/python/astra/utils.pyx
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-12-19 17:40:55 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2018-12-23 16:58:20 +0100
commit45f536a701107c1c2c5c6acb22b62737f6b634b1 (patch)
treea159a00939c6dad2bfdda46344ffd08c9934084d /python/astra/utils.pyx
parent74feef4718770d20273aa97f9176484149f178ae (diff)
downloadastra-45f536a701107c1c2c5c6acb22b62737f6b634b1.tar.gz
astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.tar.bz2
astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.tar.xz
astra-45f536a701107c1c2c5c6acb22b62737f6b634b1.zip
Fix exception propagation in python dictToConfig
Diffstat (limited to 'python/astra/utils.pyx')
-rw-r--r--python/astra/utils.pyx15
1 files changed, 9 insertions, 6 deletions
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)