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

datetime not handled correctly in python2 #25

Closed
bhaskar219 opened this issue Apr 6, 2020 · 3 comments
Closed

datetime not handled correctly in python2 #25

bhaskar219 opened this issue Apr 6, 2020 · 3 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@bhaskar219
Copy link

I.closed(datetime.date(2020,10,18),I.inf) & I.closed(datetime.date(2020,11,29),I.inf)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/intervals.py", line 101, in closed
return Interval(AtomicInterval(CLOSED, lower, upper, CLOSED))
File "/usr/lib/python2.7/site-packages/intervals.py", line 382, in init
if self.is_empty():
File "/usr/lib/python2.7/site-packages/intervals.py", line 423, in is_empty
self._lower > self._upper or
TypeError: can't compare datetime.date to instance

@AlexandreDecan
Copy link
Owner

Hello,

That's because datetime does not return NotImplemented in Python 2.7 when compared with unsupported values, so we cannot intercept comparison operators and override their behaviour with infinities.

This issue is related to #5 and cannot be solved for Python 2.7. In Python 3, your snippet works, and leads to [datetime.date(2020, 11, 29),+inf).

@AlexandreDecan AlexandreDecan added bug Something isn't working invalid This doesn't seem right labels Apr 6, 2020
@bhaskar219
Copy link
Author

Thanks for your response, If possible can you share workaround if you have. Otherwise i will plan to use python3 itself.
This module is very helpful to get the interval information.

@AlexandreDecan
Copy link
Owner

Hello,

Unfortunately, there is no easy workaround for this. I strongly recommends switching to Python 3, notably because Python 2.7 is no longer officially supported since January 2020, but also because it is not supported by portion and you're likely to have other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants