File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1501,7 +1501,7 @@ def qualname_from_function(func):
15011501
15021502 # Python 3: methods, functions, classes
15031503 if func_qualname is not None :
1504- if hasattr (func , "__module__" ):
1504+ if hasattr (func , "__module__" ) and isinstance ( func . __module__ , str ) :
15051505 func_qualname = func .__module__ + "." + func_qualname
15061506 func_qualname = prefix + func_qualname + suffix
15071507
Original file line number Diff line number Diff line change @@ -951,3 +951,23 @@ def test_format_timestamp_naive():
951951 # Ensure that some timestamp is returned, without error. We currently treat these as local time, but this is an
952952 # implementation detail which we should not assert here.
953953 assert re .fullmatch (timestamp_regex , format_timestamp (datetime_object ))
954+
955+
956+ def test_qualname_from_function_inner_function ():
957+ def test_function (): ...
958+
959+ assert (
960+ sentry_sdk .utils .qualname_from_function (test_function )
961+ == "tests.test_utils.test_qualname_from_function_inner_function.<locals>.test_function"
962+ )
963+
964+
965+ def test_qualname_from_function_none_name ():
966+ def test_function (): ...
967+
968+ test_function .__module__ = None
969+
970+ assert (
971+ sentry_sdk .utils .qualname_from_function (test_function )
972+ == "test_qualname_from_function_none_name.<locals>.test_function"
973+ )
You can’t perform that action at this time.
0 commit comments