From 6e823cfad1ea04b607e0cc67ee0ac65515f088f2 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 24 Jan 2008 14:50:30 +0000 Subject: [PATCH] Fix try: .. except: .. finally: .. constructs to make them compatible with Python < 2.5. --- pybindgen/cppclass.py | 22 ++++++++++++---------- pybindgen/typehandlers/base.py | 11 ++++++----- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index cf12a8c..6943a41 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -124,10 +124,11 @@ void set_pyobj(PyObject *pyobj) parent_caller.reset_code_generation_state() ## test code generation try: - utils.call_with_error_handling(parent_caller.generate, - (NullCodeSink(),), {}, parent_caller) - except utils.SkipWrapper: - continue + try: + utils.call_with_error_handling(parent_caller.generate, + (NullCodeSink(),), {}, parent_caller) + except utils.SkipWrapper: + continue finally: parent_caller.reset_code_generation_state() @@ -147,12 +148,13 @@ void set_pyobj(PyObject *pyobj) virtual_proxy.helper_class = self virtual_proxy.reset_code_generation_state() try: - utils.call_with_error_handling(virtual_proxy.generate, - (NullCodeSink(),), {}, virtual_proxy) - except utils.SkipWrapper: - if virtual_proxy.method.is_pure_virtual: - return False - continue + try: + utils.call_with_error_handling(virtual_proxy.generate, + (NullCodeSink(),), {}, virtual_proxy) + except utils.SkipWrapper: + if virtual_proxy.method.is_pure_virtual: + return False + continue finally: virtual_proxy.reset_code_generation_state() diff --git a/pybindgen/typehandlers/base.py b/pybindgen/typehandlers/base.py index 8adc5a0..cb6b83b 100644 --- a/pybindgen/typehandlers/base.py +++ b/pybindgen/typehandlers/base.py @@ -841,11 +841,12 @@ class ForwardWrapperBase(object): tmp_sink = codesink.NullCodeSink() try: - self.generate_body(tmp_sink) - except CodegenErrorBase: - return [] - else: - return list(set(self.meth_flags)) + try: + self.generate_body(tmp_sink) + except CodegenErrorBase: + return [] + else: + return list(set(self.meth_flags)) finally: self.reset_code_generation_state()