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(utils): Handle partialmethod in qualname_from_function (CPython 3.13) #3272

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,14 +1330,18 @@ def qualname_from_function(func):

prefix, suffix = "", ""

if hasattr(func, "_partialmethod") and isinstance(
func._partialmethod, partialmethod
):
prefix, suffix = "partialmethod(<function ", ">)"
func = func._partialmethod.func
elif isinstance(func, partial) and hasattr(func.func, "__name__"):
if isinstance(func, partial) and hasattr(func.func, "__name__"):
prefix, suffix = "partial(<function ", ">)"
func = func.func
else:
# The _partialmethod attribute of methods wrapped with partialmethod() was renamed to __partialmethod__ in CPython 3.13:
# https://github.com/python/cpython/pull/16600
partial_method = getattr(func, "_partialmethod", None) or getattr(
func, "__partialmethod__", None
)
if isinstance(partial_method, partialmethod):
prefix, suffix = "partialmethod(<function ", ">)"
func = partial_method.func

if hasattr(func, "__qualname__"):
func_qualname = func.__qualname__
Expand Down
Loading