From 2f66412afaca4a42319c666958c89827edd8f2f3 Mon Sep 17 00:00:00 2001
From: Brennan Ashton <bashton@brennanashton.com>
Date: Wed, 14 Nov 2018 17:53:22 -0800
Subject: gr-runtime: Improve exception handling in ControlPort Monitor

---
 gnuradio-runtime/python/gnuradio/eng_notation.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'gnuradio-runtime/python/gnuradio/eng_notation.py')

diff --git a/gnuradio-runtime/python/gnuradio/eng_notation.py b/gnuradio-runtime/python/gnuradio/eng_notation.py
index 391dc5838f..ec35b0db5b 100644
--- a/gnuradio-runtime/python/gnuradio/eng_notation.py
+++ b/gnuradio-runtime/python/gnuradio/eng_notation.py
@@ -23,6 +23,9 @@ Display numbers as strings using engineering notation.
 """
 from __future__ import unicode_literals
 
+import six
+
+
 scale_factor = {}
 scale_factor['E'] = 1e18
 scale_factor['P'] = 1e15
@@ -66,11 +69,13 @@ def num_to_str (n, precision=6):
 def str_to_num (value):
     '''Convert a string in engineering notation to a number.  E.g., '15m' -> 15e-3'''
     try:
+        if not isinstance(value, six.string_types):
+            raise TypeError("Value must be a string")
         scale = 1.0
         suffix = value[-1]
         if suffix in scale_factor:
             return float (value[0:-1]) * scale_factor[suffix]
         return float (value)
-    except:
-        raise RuntimeError (
+    except (TypeError, KeyError, ValueError):
+        raise ValueError (
             "Invalid engineering notation value: %r" % (value,))
-- 
cgit v1.2.3