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

Add caution to dateutil.parser.parse #1281

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ switch, and thus all their contributions are dual-licensed.
- Sherry Zhou (gh: @cssherry) **D**
- Siping Meng (gh: @smeng10) **D**
- Stefan Bonchev **D**
- Theodore Dias (gh: @madt2709) **D**
- Thierry Bastian <thierryb@MASKED>
- Thomas A Caswell <tcaswell@MASKED> (gh: @tacaswell) **R**
- Thomas Achtemichuk <tom@MASKED>
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/1270.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Added note into docs to be more explicit that passing a non-datetime strings into
``dateutil.parser.parse`` has undefined behavior.
Reported by @pganssle (gh issue #1270). Fixed by @madt2709 (gh pr #1281)
6 changes: 6 additions & 0 deletions src/dateutil/parser/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,12 @@ def parse(self, timestr, default=None,
:raises OverflowError:
Raised if the parsed date exceeds the largest valid C integer on
your system.

.. caution::

If you parse a string which is not representing a :class:`datetime.datetime` object
then it may parse to something or fail outright.

"""

if default is None:
Expand Down