Skip to content

Commit

Permalink
Merge pull request #987 from eastface/issue_981
Browse files Browse the repository at this point in the history
Fix TypeError in parser's error-wrapping logic
  • Loading branch information
pganssle committed Jan 2, 2020
2 parents f6c6d5c + a332879 commit 21fe6e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/987.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion dateutil/parser/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def parse(self, timestr, default=None,
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)
Expand Down
4 changes: 4 additions & 0 deletions dateutil/test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ def test_out_of_bound_day(self):
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):
Expand Down

0 comments on commit 21fe6e9

Please sign in to comment.