From e0a88faf2ca2b306e2ffbb32870d5ef4b4e398f0 Mon Sep 17 00:00:00 2001 From: David Dyer Date: Sun, 21 Apr 2019 20:47:16 -0400 Subject: [PATCH 1/4] test --- arrow/arrow.py | 1 + 1 file changed, 1 insertion(+) diff --git a/arrow/arrow.py b/arrow/arrow.py index 8db28bed1..d0676ea30 100644 --- a/arrow/arrow.py +++ b/arrow/arrow.py @@ -18,6 +18,7 @@ from arrow import util, locales, parser, formatter +#test class Arrow(object): '''An :class:`Arrow ` object. From abce71ed18c65c64a5e87b2c05d9a463bea6b038 Mon Sep 17 00:00:00 2001 From: David Dyer Date: Mon, 22 Apr 2019 21:05:03 -0400 Subject: [PATCH 2/4] potential bug fix --- arrow/parser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arrow/parser.py b/arrow/parser.py index e3a27ea80..77a3d570c 100644 --- a/arrow/parser.py +++ b/arrow/parser.py @@ -176,6 +176,10 @@ def parse(self, string, fmt): if match is None: raise ParserError('Failed to match \'{}\' when parsing \'{}\'' .format(fmt_pattern_re.pattern, string)) + + if match.end() != len(string): + raise ParserError('Failed to match \'{}\' when parsing \'{}\'' + .format(fmt_pattern_re.pattern, string)) parts = {} for token in fmt_tokens: if token == 'Do': From b8caffc433aae84eed5e27173aeaa9eec5073bb6 Mon Sep 17 00:00:00 2001 From: David Dyer Date: Mon, 22 Apr 2019 21:33:15 -0400 Subject: [PATCH 3/4] CI build --- arrow/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arrow/parser.py b/arrow/parser.py index 77a3d570c..ec7e2652c 100644 --- a/arrow/parser.py +++ b/arrow/parser.py @@ -177,8 +177,8 @@ def parse(self, string, fmt): raise ParserError('Failed to match \'{}\' when parsing \'{}\'' .format(fmt_pattern_re.pattern, string)) - if match.end() != len(string): - raise ParserError('Failed to match \'{}\' when parsing \'{}\'' + if match.end() != len(string) and 'Z' not in string: + raise ParserError('BUG FIX: Failed to match \'{}\' when parsing \'{}\'' .format(fmt_pattern_re.pattern, string)) parts = {} for token in fmt_tokens: From e58f0dc5500a9d2a3058cac12562be53cf0e9e21 Mon Sep 17 00:00:00 2001 From: David Dyer Date: Mon, 22 Apr 2019 21:41:07 -0400 Subject: [PATCH 4/4] coverage --- tests/parser_tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/parser_tests.py b/tests/parser_tests.py index a179be4e6..c25bb772b 100644 --- a/tests/parser_tests.py +++ b/tests/parser_tests.py @@ -272,6 +272,16 @@ def test_try_timestamp(self): assertEqual(parser.DateTimeParser._try_timestamp('1'), 1) assertEqual(parser.DateTimeParser._try_timestamp('abc'), None) + def test_too_many_year_digits_YYYY(self): + with assertRaises(parser.ParserError): + self.parser.parse('01 June 123456789101112', 'DD MMMM YYYY') + + def test_too_many_year_digits_YY(self): + with assertRaises(parser.ParserError): + self.parser.parse('01 June 2018', 'DD MMMM YY') + + + class DateTimeParserRegexTests(Chai):