Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1706070

Summary: python-tomlkit FTBFS with Python 3.8
Product: [Fedora] Fedora Reporter: Patrik Kopkan <pkopkan>
Component: python-tomlkitAssignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: decathorpe, mhroncok, tir.karthi
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: python-tomlkit-0.5.4-1.fc31 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-30 22:04:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1686977    

Description Patrik Kopkan 2019-05-03 13:24:01 UTC
python-tomlkit-0.5.3-4 fails to build with python3.8 due to failing tests.
I think it is because of some change in python3.8.

Links:
buildlog from copr: https://copr-be.cloud.fedoraproject.org/results/@python/python3.8/fedora-rawhide-x86_64/00902610-python-tomlkit/builder-live.log

recent scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=34600235 


pytest output:
============================= test session starts ==============================
platform linux -- Python 3.8.0a3, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /builddir/build/BUILD/tomlkit-0.5.3
collected 227 items

tests/test_api.py ....................................................   [ 22%]
tests/test_build.py ..                                                   [ 23%]
tests/test_items.py .............FF.....                                 [ 32%]
tests/test_parser.py .                                                   [ 33%]
tests/test_toml_document.py .................                            [ 40%]
tests/test_toml_file.py .                                                [ 40%]
tests/test_toml_tests.py ............................................... [ 61%]
........................................................................ [ 93%]
.......                                                                  [ 96%]
tests/test_utils.py .......                                              [ 99%]
tests/test_write.py .                                                    [100%]

=================================== FAILURES ===================================
_____________________ test_datetimes_behave_like_datetimes _____________________

    def test_datetimes_behave_like_datetimes():
        i = item(datetime(2018, 7, 22, 12, 34, 56))
    
        assert i == datetime(2018, 7, 22, 12, 34, 56)
        assert i.as_string() == "2018-07-22T12:34:56"
    
>       i += timedelta(days=1)

tests/test_items.py:275: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tomlkit/items.py:525: in __add__
    result = super(DateTime, self).__add__(other)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'tomlkit.items.DateTime'>, value = 2018
_ = (7, 23, 12, 34, 56, 0, ...)

    def __new__(cls, value, *_):  # type: (..., datetime, ...) -> datetime
        return datetime.__new__(
            cls,
>           value.year,
            value.month,
            value.day,
            value.hour,
            value.minute,
            value.second,
            value.microsecond,
            tzinfo=value.tzinfo,
        )
E       AttributeError: 'int' object has no attribute 'year'

tomlkit/items.py:498: AttributeError
_________________________ test_dates_behave_like_dates _________________________

    def test_dates_behave_like_dates():
        i = item(date(2018, 7, 22))
    
        assert i == date(2018, 7, 22)
        assert i.as_string() == "2018-07-22"
    
>       i += timedelta(days=1)

tests/test_items.py:295: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tomlkit/items.py:584: in __add__
    result = super(Date, self).__add__(other)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'tomlkit.items.Date'>, value = 2018, _ = (7, 23)

    def __new__(cls, value, *_):  # type: (..., date, ...) -> date
>       return date.__new__(cls, value.year, value.month, value.day)
E       AttributeError: 'int' object has no attribute 'year'

tomlkit/items.py:565: AttributeError
=============================== warnings summary ===============================
tests/test_write.py:8
  /builddir/build/BUILD/tomlkit-0.5.3/tests/test_write.py:8: SyntaxWarning: invalid escape sequence \e
    d = {"foo": "\e\u25E6\r"}

tests/test_write.py:14
  /builddir/build/BUILD/tomlkit-0.5.3/tests/test_write.py:14: SyntaxWarning: invalid escape sequence \e
    assert loads(dumps(d))["foo"] == "\e\u25E6\r"

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============== 2 failed, 225 passed, 2 warnings in 2.28 seconds ===============
error: Bad exit status from /var/tmp/rpm-tmp.DM3Urw (%check)
    Bad exit status from /var/tmp/rpm-tmp.DM3Urw (%check)

Comment 1 Fabio Valentini 2019-05-04 10:09:04 UTC
I've reported both issues (date(time) AttributeError failures, new invalid escape sequence "\e" SyntaxWarnings) upstream:

AttributeError: https://github.com/sdispater/tomlkit/issues/51
SyntaxWarning:  https://github.com/sdispater/tomlkit/issues/52

Hopefully the upstream developers can help fix this in time.

Comment 2 Miro Hrončok 2019-05-04 15:33:02 UTC
SyntaxWarning is a warning only and the test failure looks like broken tests. Worst case scenario: we ship with the test deselected.

Comment 3 Karthikeyan Singaravelan 2019-06-29 05:05:56 UTC
The datetime failures were due to return type change in datetime classes that are subclasses. Relevant CPython PR https://github.com/python/cpython/pull/10902 . This seems to be an intentional backwards incompatible change as I can see from Whats new entry text and discussion.

Arithmetic operations between subclasses of :class:`datetime.date` or
:class:`datetime.datetime` and :class:`datetime.timedelta` objects now return
an instance of the subclass, rather than the base class. This also affects
the return type of operations whose implementation (directly or indirectly)
uses :class:`datetime.timedelta` arithmetic, such as
:meth:`datetime.datetime.astimezone`.