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

Fix for Python 3.10 (released 2021-10-04) #68

Merged
merged 4 commits into from Dec 12, 2021
Merged

Fix for Python 3.10 (released 2021-10-04) #68

merged 4 commits into from Dec 12, 2021

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Sep 13, 2021

Fixes #58.
Fixes #67.

Python 3.10 is due out on 2021-10-04, three weeks from now.

https://discuss.python.org/t/python-3-10-0rc2-is-now-available/10496?u=hugovk

This deprecation warning was added in Python 3.8:

DeprecationWarning: an integer is required (got type decimal.Decimal). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.

For example:

Python 3.8.6 (v3.8.6:db455296be, Sep 23 2020, 13:31:39)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime as dt
>>> from isodate import Duration
>>> dt.date(2000, 3, 30) + Duration(days=1)
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/isodate/duration.py:183: DeprecationWarning: an integer is required (got type decimal.Decimal).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  newdt = other.replace(year=newyear, month=newmonth, day=newday)
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/isodate/duration.py:183: DeprecationWarning: an integer is required (got type decimal.Decimal).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  newdt = other.replace(year=newyear, month=newmonth, day=newday)
datetime.date(2000, 3, 31)
>>>

https://bugs.python.org/issue36048

In Python 3.10 it is now an error:

TypeError: 'decimal.Decimal' object cannot be interpreted as an integer

For example:

Python 3.10.0rc2+ (heads/3.10:a272ffe, Sep  8 2021, 11:20:24) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime as dt
>>> from isodate import Duration
>>> dt.date(2000, 3, 30) + Duration(days=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/hugo/.pyenv/versions/3.10-dev/lib/python3.10/site-packages/isodate/duration.py", line 183, in __add__
    newdt = other.replace(year=newyear, month=newmonth, day=newday)
TypeError: 'decimal.Decimal' object cannot be interpreted as an integer
>>>

https://bugs.python.org/issue37999

Failing build without fix:

Passing build with fix:

isodate is downloaded from PyPI 33 million times a month, the 52nd most popular package (https://hugovk.github.io/top-pypi-packages/), therefore I recommend making a release before 2021-10-04.


This PR also switches from Travis CI to GitHub Actions and Coveralls to Codecov, taken from #66, because testing on Travis CI is more difficult now. It only adds testing for supported Python versions. Let me know if this commit should be dropped, but I'd recommend merging #66 as well.

This was referenced Sep 13, 2021
@hugovk
Copy link
Contributor Author

hugovk commented Sep 13, 2021

This has some overlap with PR #60.

@hugovk
Copy link
Contributor Author

hugovk commented Oct 25, 2021

I've put up a temporary fork with this Python 3.10 fix as isodate2 0.7.0 at https://pypi.org/project/isodate2/

@danilaeremin
Copy link

Merge?

@hugovk
Copy link
Contributor Author

hugovk commented Nov 6, 2021

Fixed in the fork at https://github.com/isodate/isodate/pull/1.

@hugovk hugovk mentioned this pull request Nov 8, 2021
1 task
@nicholascar
Copy link

nicholascar commented Dec 9, 2021

The maintainer has indicated, separately to GitHub, that this is likely to be merged soon!

@gweis gweis merged commit 5784645 into gweis:master Dec 12, 2021
@hugovk hugovk deleted the add-3.10 branch December 12, 2021 22:47
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 this pull request may close these issues.

0.6.0: pytest warnings Python 3.8 compatibility
5 participants