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

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

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.

Commits

Files