Bug 2293092 - pytohn-decopatch fails to build with Python 3.13 in Fedora Rawhide (41): stripped docstring indentation
Summary: pytohn-decopatch fails to build with Python 3.13 in Fedora Rawhide (41): stri...
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: python-decopatch
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Zbigniew Jędrzejewski-Szmek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13 F41FTBFS
TreeView+ depends on / blocked
 
Reported: 2024-06-19 14:51 UTC by Karolina Surma
Modified: 2024-06-29 08:36 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-06-29 08:36:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2024-06-19 14:51:10 UTC
pytohn-decopatch fails to build with Python 3.13 in Fedora Rawhide (41).

Build failure - Python now always strips the whitespaces from docstrings.

=================================== FAILURES ===================================
__________________ test_doc_add_tag_function[flat_mode=False] __________________
flat_mode = False
    @pytest.mark.parametrize('flat_mode', [False, True], ids="flat_mode={}".format)
    def test_doc_add_tag_function(flat_mode):
        """ Tests that the @add_tag example from doc (functions only) works """
    
        if not flat_mode:
            @function_decorator
            def add_tag(tag='hi!'):
                """
                Example decorator to add a 'tag' attribute to a function.
                :param tag: the 'tag' value to set on the decorated function (default 'hi!).
                """
                def apply_decorator(f):
                    """
                    This is the method that will be called when your decorator is used on a
                    function `f`. It should return the replacement for this function (it can
                    be the same object, or another one, not even a function!)
                    """
                    setattr(f, 'tag', tag)
                    return f
    
                return apply_decorator
    
        else:
            @function_decorator
            def add_tag(tag='hi!', f=DECORATED):
                """
                Example decorator to add a 'tag' attribute to a function.
                :param tag: the 'tag' value to set on the decorated function (default 'hi!).
                """
                setattr(f, 'tag', tag)
                return f
    
        @add_tag
        def foo():
            pass
    
        assert foo.tag == 'hi!'
    
        @add_tag()
        def foo():
            pass
    
        assert foo.tag == 'hi!'
    
        @add_tag('hello')
        def foo():
            pass
    
        assert foo.tag == 'hello'
    
        # manual mode
        add_tag()(foo)
        assert foo.tag == 'hi!'
    
        # signature and help
        assert "%s%s" % (add_tag.__name__, signature(add_tag)) == "add_tag(tag='hi!')"
        print(help(add_tag))
>       assert add_tag.__doc__ == """
                Example decorator to add a 'tag' attribute to a function.
                :param tag: the 'tag' value to set on the decorated function (default 'hi!).
                """
E       assert "\nExample decorator to add a 'tag' attribute to a function.\n:param tag: the 'tag' value to set on the decorated function (default 'hi!).\n" == "\n            Example decorator to add a 'tag' attribute to a function.\n            :param tag: the 'tag' value to set on the decorated function (default 'hi!).\n            "
E           
E         -             Example decorator to add a 'tag' attribute to a function.
E         ? ------------
E         + Example decorator to add a 'tag' attribute to a function.
E         -             :param tag: the 'tag' value to set on the decorated function (default 'hi!).
E         ? ------------
E         + :param tag: the 'tag' value to set on the decorated function (default 'hi!).
E         -
tests/test_doc.py:72: AssertionError
----------------------------- Captured stdout call -----------------------------
Help on function add_tag in module tests.test_doc:
add_tag(tag='hi!')
    Example decorator to add a 'tag' attribute to a function.
    :param tag: the 'tag' value to set on the decorated function (default 'hi!).
None
__________________ test_doc_add_tag_function[flat_mode=True] ___________________
flat_mode = True
    @pytest.mark.parametrize('flat_mode', [False, True], ids="flat_mode={}".format)
    def test_doc_add_tag_function(flat_mode):
        """ Tests that the @add_tag example from doc (functions only) works """
    
        if not flat_mode:
            @function_decorator
            def add_tag(tag='hi!'):
                """
                Example decorator to add a 'tag' attribute to a function.
                :param tag: the 'tag' value to set on the decorated function (default 'hi!).
                """
                def apply_decorator(f):
                    """
                    This is the method that will be called when your decorator is used on a
                    function `f`. It should return the replacement for this function (it can
                    be the same object, or another one, not even a function!)
                    """
                    setattr(f, 'tag', tag)
                    return f
    
                return apply_decorator
    
        else:
            @function_decorator
            def add_tag(tag='hi!', f=DECORATED):
                """
                Example decorator to add a 'tag' attribute to a function.
                :param tag: the 'tag' value to set on the decorated function (default 'hi!).
                """
                setattr(f, 'tag', tag)
                return f
    
        @add_tag
        def foo():
            pass
    
        assert foo.tag == 'hi!'
    
        @add_tag()
        def foo():
            pass
    
        assert foo.tag == 'hi!'
    
        @add_tag('hello')
        def foo():
            pass
    
        assert foo.tag == 'hello'
    
        # manual mode
        add_tag()(foo)
        assert foo.tag == 'hi!'
    
        # signature and help
        assert "%s%s" % (add_tag.__name__, signature(add_tag)) == "add_tag(tag='hi!')"
        print(help(add_tag))
>       assert add_tag.__doc__ == """
                Example decorator to add a 'tag' attribute to a function.
                :param tag: the 'tag' value to set on the decorated function (default 'hi!).
                """
E       assert "\nExample decorator to add a 'tag' attribute to a function.\n:param tag: the 'tag' value to set on the decorated function (default 'hi!).\n" == "\n            Example decorator to add a 'tag' attribute to a function.\n            :param tag: the 'tag' value to set on the decorated function (default 'hi!).\n            "
E           
E         -             Example decorator to add a 'tag' attribute to a function.
E         ? ------------
E         + Example decorator to add a 'tag' attribute to a function.
E         -             :param tag: the 'tag' value to set on the decorated function (default 'hi!).
E         ? ------------
E         + :param tag: the 'tag' value to set on the decorated function (default 'hi!).
E         -
tests/test_doc.py:72: AssertionError
----------------------------- Captured stdout call -----------------------------
Help on function add_tag in module tests.test_doc:
add_tag(tag='hi!')
    Example decorator to add a 'tag' attribute to a function.
    :param tag: the 'tag' value to set on the decorated function (default 'hi!).
None
=========================== short test summary info ============================
FAILED tests/test_doc.py::test_doc_add_tag_function[flat_mode=False] - assert...
FAILED tests/test_doc.py::test_doc_add_tag_function[flat_mode=True] - assert ...
================== 2 failed, 184 passed, 80 skipped in 1.13s ===================


Let us know here if you have any questions.
Python 3.13 is planned to be included in Fedora 41.

Comment 1 Sandro 2024-06-29 08:36:19 UTC
Has been rebuilt against Python 3.13 in rawhide. Closing.


Note You need to log in before you can comment on or make changes to this bug.