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 @@ -1462,7 +1462,7 @@ def qualname_from_function(func):
14621462
14631463 # Python 3: methods, functions, classes
14641464 if func_qualname is not None :
1465- if hasattr (func , "__module__" ):
1465+ if hasattr (func , "__module__" ) and isinstance ( func . __module__ , str ) :
14661466 func_qualname = func .__module__ + "." + func_qualname
14671467 func_qualname = prefix + func_qualname + suffix
14681468
Original file line number Diff line number Diff line change @@ -983,3 +983,23 @@ def test_serialize_span_attribute(value, result):
983983)
984984def test_datetime_from_isoformat (input_str , expected_output ):
985985 assert datetime_from_isoformat (input_str ) == expected_output , input_str
986+
987+
988+ def test_qualname_from_function_inner_function ():
989+ def test_function (): ...
990+
991+ assert (
992+ sentry_sdk .utils .qualname_from_function (test_function )
993+ == "tests.test_utils.test_qualname_from_function_inner_function.<locals>.test_function"
994+ )
995+
996+
997+ def test_qualname_from_function_none_name ():
998+ def test_function (): ...
999+
1000+ test_function .__module__ = None
1001+
1002+ assert (
1003+ sentry_sdk .utils .qualname_from_function (test_function )
1004+ == "test_qualname_from_function_none_name.<locals>.test_function"
1005+ )
You can’t perform that action at this time.
0 commit comments