• 
      

    Fix a recursion error that can occur when copying webapi decorator state.

    Review Request #13952 — Created June 5, 2024 and submitted

    Information

    Djblets
    release-5.x

    Reviewers

    When setting up webapi decorator state, we use Python's
    functools.update_wrapper() to copy over standard function state. This
    is good except if we're working with the same function as both the
    source and target, then we can get into a state where we reach an
    infinite loop.

    This seems to be due to setting __wrapped__ on the function to point
    to itself. This hasn't resulted in any issues in normal usage, but it
    has impacted Sphinx during doc generation, as it just hits an infinite
    loop walking the tree.

    We now bail out immediately if we determine we're using the same
    function for both arguments.

    Unit tests pass.

    Verified this got past a stuck state in Sphinx doc building.

    Summary ID
    Fix a recursion error that can occur when copying webapi decorator state.
    When setting up webapi decorator state, we use Python's `functools.update_wrapper()` to copy over standard function state. This is good except if we're working with the same function as both the source and target, then we can get into a state where we reach an infinite loop. This seems to be due to setting `__wrapped__` on the function to point to itself. This hasn't resulted in any issues in normal usage, but it has impacted Sphinx during doc generation, as it just hits an infinite loop walking the tree. We now bail out immediately if we determine we're using the same function for both arguments.
    248a699fc14dba9eb45fffdb68bdf38165f067fb
    maubin
    1. Ship It!
    2. 
        
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-5.x (768c128)