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

Invalid datemath expression can lead to NoneType #25

Closed
kasium opened this issue Apr 13, 2021 · 5 comments
Closed

Invalid datemath expression can lead to NoneType #25

kasium opened this issue Apr 13, 2021 · 5 comments
Assignees
Labels

Comments

@kasium
Copy link

kasium commented Apr 13, 2021

Hi,

when datemath gets an invalid argument, it can happen that None is returned instead of an exception.
This is can lead to a weird NoneType if datemath.datemath is used instead of datemath.parse.

import datemath

type(datemath.parse("2")) # --> None

datemath.datemath("2")   # AttributeError: 'NoneType' object has no attribute 'datetime'

I use version 1.5.2 (latest). It would be great if both cases could raise a parse exception.

Thanks,
Kai

@nickmaccarthy nickmaccarthy self-assigned this Apr 16, 2021
@nickmaccarthy nickmaccarthy mentioned this issue Apr 16, 2021
@nickmaccarthy
Copy link
Owner

Thanks for bringing this up @iakum . I believe I have fixed it. Would you mind testing out branch issue_25 (PR should be linked in this issue) and see if that fixes your problem? If it does, I'll create version 1.5.3 and get it out on pypi

@nickmaccarthy
Copy link
Owner

PR for reference: #26

@kasium
Copy link
Author

kasium commented Apr 19, 2021

Works perfectly! Thanks

@nickmaccarthy
Copy link
Owner

perfect @iakum , i just release v1.5.4, let me know if that works for you and I will close this issue out.

@kasium
Copy link
Author

kasium commented Apr 21, 2021

Works perfectly. Thanks a lot

@kasium kasium closed this as completed Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants