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

Unhandled TypeError exception instead of ParserError #1108

Open
espdev opened this issue Mar 10, 2021 · 2 comments
Open

Unhandled TypeError exception instead of ParserError #1108

espdev opened this issue Mar 10, 2021 · 2 comments

Comments

@espdev
Copy link

espdev commented Mar 10, 2021

Just try to run:

from dateutil.parser import parse
parse('19/040400')

Expected: ParserError
Actual:

File "dateutil/parser/_parser.py", line 1374, in parse
  return DEFAULTPARSER.parse(timestr, **kwargs)
File "dateutil/parser/_parser.py", line 657, in parse
  six.raise_from(ParserError(e.args[0] + ": %s", timestr), e)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
@DOH-Manada
Copy link

DOH-Manada commented Mar 11, 2021

I know PR #881 added the ParseError exception, but this will throw an AttributeError:

  try:
      datetime_object = dateutil.parser.parse(date_string.replace("AM", '').replace("PM",''))
  except dateutil.parser.ParseError:
      datetime_object = datetime.datetime(3000, 1, 1, 1, 1) # arbitary future date

@espdev espdev changed the title Unhandled TypeError exception instead of ParseError Unhandled TypeError exception instead of ParserError Mar 11, 2021
@espdev
Copy link
Author

espdev commented Mar 11, 2021

@DOH-Manada

I think you mean except dateutil.parser.ParserError:

ParserError instead of ParseError. I have fixed the issue title. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants