From 79092ec57262d4a1131483509d327c77f79eacf0 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 8 Nov 2023 16:21:54 +0000 Subject: [PATCH] bt2: require msg for _OverflowError in _handle_func_status Pyright says: /home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/utils.py:160:19 - error: Invalid exception class or object Constructor for exception type "type[_OverflowError]" requires one or more arguments (reportGeneralTypeIssues) That's true, _OverflowError has bt2_error._Error as a base, which requires a message. Change _handle_func_status to assert that a msg was provided when handling that case. Change-Id: I961c336cf53ce13e5f4241728e1131cccb77efcf Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11297 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/bindings/python/bt2/bt2/utils.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index c8fb5171..fc6d24ce 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -156,10 +156,7 @@ def _handle_func_status(status, msg=None): else: raise TryAgain(msg) elif status == native_bt.__BT_FUNC_STATUS_OVERFLOW_ERROR: - if msg is None: - raise _OverflowError - else: - raise _OverflowError(msg) + raise _OverflowError(msg) elif status == native_bt.__BT_FUNC_STATUS_UNKNOWN_OBJECT: if msg is None: raise UnknownObject -- 2.34.1