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

Wrong exception when parsing string with trailing or leading slash #506

Open
2 tasks done
fffaez opened this issue Oct 16, 2020 · 0 comments · May be fixed by #505
Open
2 tasks done

Wrong exception when parsing string with trailing or leading slash #506

fffaez opened this issue Oct 16, 2020 · 0 comments · May be fixed by #505

Comments

@fffaez
Copy link

fffaez commented Oct 16, 2020

  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: Ubuntu 18.04.3 LTS
  • Pendulum version: 2.1.1

Issue

Parsing any string that begins or ends with a slash returns a IndexError instead of ValueError:

>>> from pendulum.parsing import parse
>>> parse("/2020")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/pendulum/pendulum/parsing/__init__.py", line 74, in parse
    return _normalize(_parse(text, **_options), **_options)
  File "/home/ubuntu/pendulum/pendulum/parsing/__init__.py", line 115, in _parse
    return _parse_iso8601_interval(text)
  File "/home/ubuntu/pendulum/pendulum/parsing/__init__.py", line 221, in _parse_iso8601_interval
    if first[0] == "P":
IndexError: string index out of range
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

Successfully merging a pull request may close this issue.

1 participant