File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -954,7 +954,8 @@ def _short_repr(obj):
954954 return name + ' (bound)'
955955 else :
956956 return name
957- if _isinstance (obj , types .LambdaType ):
957+ # NB: types.LambdaType is an alias for types.FunctionType!
958+ if _isinstance (obj , types .LambdaType ) and obj .__name__ == '<lambda>' :
958959 return 'lambda: %s:%s' % (os .path .basename (obj .__code__ .co_filename ),
959960 obj .__code__ .co_firstlineno )
960961 if _isinstance (obj , types .FrameType ):
Original file line number Diff line number Diff line change @@ -428,6 +428,14 @@ def test_short_repr_lambda(self):
428428 self .assertEqual ('lambda: tests.py:%s' % lambda_lineno ,
429429 objgraph ._short_repr (f ))
430430
431+ def test_short_repr_function (self ):
432+ self .assertRegex (objgraph ._short_repr (sample_func ),
433+ 'function sample_func at .*' )
434+
435+
436+ def sample_func ():
437+ pass
438+
431439
432440class StubSubprocess (object ):
433441
You can’t perform that action at this time.
0 commit comments