Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError in parser's error-wrapping logic #987

Merged
merged 2 commits into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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