From e67f718ce868017927842a555108c0a78d5118d3 Mon Sep 17 00:00:00 2001 From: "Mark E. Shoulson" Date: Fri, 3 Sep 2021 10:43:03 -0400 Subject: [PATCH] Address issue #253 UnicodeDecodeError was being treated as a ValueError, since it is a subclass, but it doesn't have the .message attribute, which caused an uncaught exception. --- bin/q.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/q.py b/bin/q.py index 59ecc882..4d54445d 100755 --- a/bin/q.py +++ b/bin/q.py @@ -864,7 +864,7 @@ def py3_encoded_csv_reader(encoding, f, dialect, is_stdin,**kwargs): for row in csv_reader: yield row except ValueError as e: - if e.message is not None and e.message.startswith('could not convert string to'): + if getattr(e, "message", None) is not None and e.message.startswith('could not convert string to'): raise CouldNotConvertStringToNumericValueException(e.message) else: raise CouldNotParseInputException(str(e)) @@ -887,7 +887,7 @@ def py2_encoded_csv_reader(encoding, f, dialect, is_stdin, **kwargs): for row in csv_reader: yield row except ValueError as e: - if e.message is not None and e.message.startswith('could not convert string to'): + if getattr(e, "message", None) is not None and e.message.startswith('could not convert string to'): raise CouldNotConvertStringToNumericValueException(e.message) else: raise CouldNotParseInputException(str(e))