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):
1462
1462
1463
1463
# Python 3: methods, functions, classes
1464
1464
if func_qualname is not None :
1465
- if hasattr (func , "__module__" ):
1465
+ if hasattr (func , "__module__" ) and isinstance ( func . __module__ , str ) :
1466
1466
func_qualname = func .__module__ + "." + func_qualname
1467
1467
func_qualname = prefix + func_qualname + suffix
1468
1468
Original file line number Diff line number Diff line change @@ -983,3 +983,23 @@ def test_serialize_span_attribute(value, result):
983
983
)
984
984
def test_datetime_from_isoformat (input_str , expected_output ):
985
985
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