From 067411a35264bd8f5645dc7585dcea8027bfa3bc Mon Sep 17 00:00:00 2001 From: Lars Amsel Date: Tue, 15 Jun 2021 15:05:34 +0200 Subject: cal: Remove silent capture of TypeError Remove the silent capture of TypeError because it would also catch TypeErrors is initilization errors in class creation. Instead check obj to be a class first to ensure issubclass wont throw a TypeError. --- host/python/uhd/usrp/cal/usrp_calibrator.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'host') diff --git a/host/python/uhd/usrp/cal/usrp_calibrator.py b/host/python/uhd/usrp/cal/usrp_calibrator.py index a665564ba..f409072d4 100644 --- a/host/python/uhd/usrp/cal/usrp_calibrator.py +++ b/host/python/uhd/usrp/cal/usrp_calibrator.py @@ -411,11 +411,9 @@ def get_usrp_calibrator(usrp, meas_dev, direction, **kwargs): raise RuntimeError("Could not determine USRP type!") print("=== Detected USRP type:", usrp_type) for _, obj in inspect.getmembers(sys.modules[__name__]): - try: - if issubclass(obj, USRPCalibratorBase) \ - and usrp_type in getattr(obj, 'mboard_ids', ''): - return obj(usrp, meas_dev, direction, **kwargs) - except TypeError: - continue + if (inspect.isclass(obj) and + issubclass(obj, USRPCalibratorBase) and + usrp_type in getattr(obj, 'mboard_ids', '')): + return obj(usrp, meas_dev, direction, **kwargs) raise RuntimeError("No USRP calibrator object found for device type: {}" .format(usrp_type)) -- cgit v1.2.3