From 8f5ef52a2ab3ad39e0bf978b47b60251d6397fb7 Mon Sep 17 00:00:00 2001 From: Kyle Stark Date: Tue, 8 Feb 2022 17:53:58 -0800 Subject: [PATCH] Add default message attribute The `message` attribute on ValueError has been deprecated since 2.6 and removed in Python 3. Explicitly add it ourselves for our subclasses. Fixes #2 --- fwffr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fwffr.py b/fwffr.py index e57b075..5191496 100644 --- a/fwffr.py +++ b/fwffr.py @@ -8,7 +8,6 @@ PY3 = sys.version_info[0] == 3 -__all__ = [ 'FixedLengthError', 'FixedLengthUnknownRecordTypeError', 'FixedLengthSeparatorError', @@ -26,6 +25,9 @@ def iteritems(d, **kw): class FixedLengthError(ValueError): """ Base class for parsing errors """ + + def __init__(self, message=None): + self.message = message def __str__(self): return self.message