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. diff --git a/arrow/parser.py b/arrow/parser.py index e3a27ea80..ec7e2652c 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) 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: if token == 'Do': 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):