From ea7f441b455cabbae2bf98f2d10fd11724001155 Mon Sep 17 00:00:00 2001 From: Paul Ganssle Date: Thu, 2 Jan 2020 11:54:27 -0500 Subject: Fix custom repr for ParserError This was originally dead code, because an indentation error had `__repr__` defined after the `return` statement in `__str__`. The definition of the `__repr__` is also changed to be more in line with the conception of a repr as "what you would have to evalue to get this object". Even though this is not guaranteed behavior, this commit also adds a regression test to avoid simple errors like this in the future. --- dateutil/parser/_parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'dateutil/parser/_parser.py') diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py index 7fcfa54..8d67584 100644 --- a/dateutil/parser/_parser.py +++ b/dateutil/parser/_parser.py @@ -1600,8 +1600,9 @@ class ParserError(ValueError): except (TypeError, IndexError): return super(ParserError, self).__str__() - def __repr__(self): - return "%s(%s)" % (self.__class__.__name__, str(self)) + def __repr__(self): + args = ", ".join("'%s'" % arg for arg in self.args) + return "%s(%s)" % (self.__class__.__name__, args) class UnknownTimezoneWarning(RuntimeWarning): -- cgit v1.2.1