summaryrefslogtreecommitdiff
path: root/src/pyinterp.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-08 13:36:21 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-08 13:36:21 -0500
commit55c7792c9329f97dd19fc5aeca466cb2de4fbf9c (patch)
treeb820b7c4b064e5d430439839768aa5b855ce3a4a /src/pyinterp.cc
parent3f00f8362c2fdfae1dbb6517bc29c75e308bc4f0 (diff)
parent60059750061fe59c83adc869f36335a083955608 (diff)
downloadfork-ledger-55c7792c9329f97dd19fc5aeca466cb2de4fbf9c.tar.gz
fork-ledger-55c7792c9329f97dd19fc5aeca466cb2de4fbf9c.tar.bz2
fork-ledger-55c7792c9329f97dd19fc5aeca466cb2de4fbf9c.zip
Merge branch 'next'
Diffstat (limited to 'src/pyinterp.cc')
-rw-r--r--src/pyinterp.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/pyinterp.cc b/src/pyinterp.cc
index 3c86ed4b..6a2dea03 100644
--- a/src/pyinterp.cc
+++ b/src/pyinterp.cc
@@ -255,12 +255,22 @@ value_t python_interpreter_t::python_command(call_scope_t& args)
std::strcpy(argv[i + 1], arg.c_str());
}
- int status = Py_Main(static_cast<int>(args.size()) + 1, argv);
+ int status;
+ try {
+ status = Py_Main(static_cast<int>(args.size()) + 1, argv);
+ }
+ catch (...) {
+ for (std::size_t i = 0; i < args.size() + 1; i++)
+ delete[] argv[i];
+ delete[] argv;
+ throw;
+ }
+
for (std::size_t i = 0; i < args.size() + 1; i++)
delete[] argv[i];
delete[] argv;
-
+
if (status != 0)
throw status;
@@ -287,6 +297,9 @@ expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
switch (kind) {
case symbol_t::FUNCTION:
+ if (option_t<python_interpreter_t> * handler = lookup_option(name.c_str()))
+ return MAKE_OPT_FUNCTOR(python_interpreter_t, handler);
+
if (is_initialized && main_nspace.has_key(name.c_str())) {
DEBUG("python.interp", "Python lookup: " << name);
@@ -354,14 +367,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
std::signal(SIGINT, sigint_handler);
if (val.check())
return val();
-#if 1
- // jww (2009-02-24): Distinguish between "no return" and values with
- // unconvertable type
return NULL_VALUE;
-#else
- throw_(calc_error,
- _("Could not evaluate Python variable '%1'") << name);
-#endif
}
else if (args.size() > 0) {
list arglist;