diff options
author | Paul Ganssle <paul@ganssle.io> | 2020-01-02 12:59:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 12:59:10 -0500 |
commit | 21fe6e9669191b413e59cd9abd22610191575c1f (patch) | |
tree | cb0931a0d9b4b2d9ef3c44bd9e9b827647d4e39d | |
parent | f6c6d5cb97ce460c9510846bf14e945b2b16ead0 (diff) | |
parent | a33287920ce8c3cbf99bf50b858e6081750aa0e8 (diff) | |
download | dateutil-git-21fe6e9669191b413e59cd9abd22610191575c1f.tar.gz |
Merge pull request #987 from eastface/issue_981
Fix TypeError in parser's error-wrapping logic
-rw-r--r-- | AUTHORS.md | 1 | ||||
-rw-r--r-- | changelog.d/987.bugfix.rst | 4 | ||||
-rw-r--r-- | dateutil/parser/_parser.py | 2 | ||||
-rw-r--r-- | dateutil/test/test_parser.py | 4 |
4 files changed, 10 insertions, 1 deletions
@@ -70,6 +70,7 @@ switch, and thus all their contributions are dual-licensed. - Lauren Oldja <oldja@MASKED> (gh: @loldja) **D** - Luca Ferocino <luca.ferox@MASKED> (gh: @lucaferocino) **D** - Mario Corchero <mcorcherojim@MASKED> (gh: @mariocj89) **R** +- Mark Bailey <msb@MASKED> **D** - Mateusz Dziedzic (gh: @m-dz) **D** - Matt Cooper <vtbassmatt@MASKED> (gh: @vtbassmatt) **D** - Matthew Schinckel <matt@MASKED> diff --git a/changelog.d/987.bugfix.rst b/changelog.d/987.bugfix.rst new file mode 100644 index 0000000..8bc3cdd --- /dev/null +++ b/changelog.d/987.bugfix.rst @@ -0,0 +1,4 @@ +Fixed a bug in the parser where non-``ValueError`` exceptions would be raised +during exception handling; this would happen, for example, if an +``IllegalMonthError`` was raised in ``dateutil`` code. Fixed by Mark Bailey. +(gh issue #981, pr #987). 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) diff --git a/dateutil/test/test_parser.py b/dateutil/test/test_parser.py index 726156c..605705e 100644 --- a/dateutil/test/test_parser.py +++ b/dateutil/test/test_parser.py @@ -743,6 +743,10 @@ class TestOutOfBounds(object): with pytest.raises(ParserError): parse("Feb 30, 2007") + def test_illegal_month_error(self): + with pytest.raises(ParserError): + parse("0-100") + def test_day_sanity(self, fuzzy): dstr = "2014-15-25" with pytest.raises(ParserError): |