From 79d2e486a34911ada6d81701f14dd3c4b9790afd Mon Sep 17 00:00:00 2001 From: Mark Bailey Date: Mon, 23 Dec 2019 22:46:03 +0000 Subject: Fix TypeError in parser wrapper logic In attempting to pass-through the string representation of an exception we are wrapping, we made the erroneous assumption that `args[0]` would always be a string (or something that can concatenate cleanly with a string). This turns out not to be the case with `IllegalMonthError`, where it is an integer, so to avoid raising an erroneous `TypeError`, we first convert the wrapped exception to a string. See GH issue #981. --- dateutil/parser/_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dateutil/parser/_parser.py') diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py index 458aa6a..7fcfa54 100644 --- a/dateutil/parser/_parser.py +++ b/dateutil/parser/_parser.py @@ -654,7 +654,7 @@ class parser(object): try: ret = self._build_naive(res, default) except ValueError as e: - six.raise_from(ParserError(e.args[0] + ": %s", timestr), e) + six.raise_from(ParserError(str(e) + ": %s", timestr), e) if not ignoretz: ret = self._build_tzaware(ret, res, tzinfos) -- cgit v1.2.1