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

ValueError is raised instead of returning None for 'parse(". day")' #15

Open
Delgan opened this issue Oct 14, 2017 · 0 comments
Open

ValueError is raised instead of returning None for 'parse(". day")' #15

Delgan opened this issue Oct 14, 2017 · 0 comments

Comments

@Delgan
Copy link

Delgan commented Oct 14, 2017

Hello.

I just noticed a small bug. This is not very important, but it's a little inconsistent with the rest of the library which returns None when unable to parse the string.

>>> from pytimeparse import parse
>>> parse(". day")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/env/lib/python3.6/site-packages/pytimeparse/timeparse.py", line 176, in timeparse
    list(mdict.items()) if k != 'secs' and v is not None])) +
  File "/home/env/lib/python3.6/site-packages/pytimeparse/timeparse.py", line 176, in <listcomp>
    list(mdict.items()) if k != 'secs' and v is not None])) +
ValueError: could not convert string to float: '.'

Python 3.6.3 and pytimeparse 1.1.7.

I guess this is because of the regex [\d.]+ which do not filter out such wrongly formatted float values.

onegreyonewhite added a commit to onegreyonewhite/pytimeparse2 that referenced this issue Nov 3, 2021
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

1 participant