From bd91c52d57f391007b0e294e5ee2a7fb4150f3c6 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 1 Jun 2021 15:51:23 +0800 Subject: [PATCH] Fix bare exception from str(obj) There is no test coverage for these exception clauses, however the invocation of obj.__str__() for client objects could raise any exception, hence the very broad exception catch. --- capnp/lib/capnp.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index 0ff15a4..93dd21a 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -89,7 +89,7 @@ cdef api VoidPromise * call_server_method(PyObject * _server, warning_msg = ( "Server function ({}) returned a value that was not a Promise: return = {}" .format(method_name, str(ret))) - except: + except Exception: warning_msg = 'Server function (%s) returned a value that was not a Promise' % (method_name) _warnings.warn_explicit( warning_msg, UserWarning, _inspect.getsourcefile(func), _inspect.getsourcelines(func)[1]) @@ -104,7 +104,7 @@ cdef api VoidPromise * call_server_method(PyObject * _server, warning_msg = ( "Server function ({}) returned a value that was not a Promise: return = {}" .format(method_name, str(ret))) - except: + except Exception: warning_msg = 'Server function (%s) returned a value that was not a Promise' % (method_name) _warnings.warn_explicit( warning_msg, UserWarning, _inspect.getsourcefile(func), _inspect.getsourcelines(func)[1]) @@ -289,7 +289,7 @@ cdef api object get_exception_info(object exc_type, object exc_obj, object exc_t return (exc_tb.tb_frame.f_code.co_filename.encode(), exc_tb.tb_lineno, (repr(exc_type) + ":" + str(exc_obj)).encode()) - except: + except Exception: return (b'', 0, b"Couldn't determine python exception")