From 9b2c2b603297ac494e06543c9937a222b6c81649 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 7 Nov 2009 06:40:25 -0500 Subject: Python vars of unconvertable type return NULL_VALUE --- src/pyinterp.cc | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/pyinterp.cc') diff --git a/src/pyinterp.cc b/src/pyinterp.cc index 3c86ed4b..b9e1a0e0 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -354,14 +354,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; -- cgit v1.2.3 From 47c1089c61db32f85777847c88f4aed6ef2fc050 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 7 Nov 2009 20:00:34 -0500 Subject: Make sure to clean up memory after a Python exception --- src/pyinterp.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/pyinterp.cc') diff --git a/src/pyinterp.cc b/src/pyinterp.cc index b9e1a0e0..2df82563 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(args.size()) + 1, argv); + int status; + try { + status = Py_Main(static_cast(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; -- cgit v1.2.3 From 60059750061fe59c83adc869f36335a083955608 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 8 Nov 2009 13:36:16 -0500 Subject: Check for Python options before functions --- src/pyinterp.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pyinterp.cc') diff --git a/src/pyinterp.cc b/src/pyinterp.cc index 2df82563..6a2dea03 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -297,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 * 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); -- cgit v1.2.3