# HG changeset patch # User Martin von Zweigbergk # Date 1701970267 28800 # Node ID 933551630b0d7027e0ce67cbbad13e8afcae1395 # Parent 77b86226dde20e49917658a6490a60bc1b4b7ce5 statprof: handle `lineno == None` in more cases This continues the work from 972f3e5c94b8. We saw a crash on line 956 but I updated lots of other places as well. diff -r 77b86226dde2 -r 933551630b0d mercurial/statprof.py --- a/mercurial/statprof.py Thu Dec 07 14:28:31 2023 +0100 +++ b/mercurial/statprof.py Thu Dec 07 09:31:07 2023 -0800 @@ -384,7 +384,7 @@ time = sample.time stack = sample.stack sites = [ - b'\1'.join([s.path, b'%d' % s.lineno, s.function]) + b'\1'.join([s.path, b'%d' % s.lineno or -1, s.function]) for s in stack ] file.write(b"%d\0%s\n" % (time, b'\0'.join(sites))) @@ -663,7 +663,7 @@ count / relevant_samples * 100, pycompat.fsencode(parent.filename()), pycompat.sysbytes(parent.function), - parent.lineno, + parent.lineno or -1, pycompat.sysbytes(parent.getsource(50)), ) ) @@ -705,7 +705,7 @@ b' %6.2f%% line %s: %s\n' % ( count / relevant_samples * 100, - child.lineno, + child.lineno or -1, pycompat.sysbytes(child.getsource(50)), ) ) @@ -865,7 +865,7 @@ stack.append( ( pycompat.sysstr(frame.path), - frame.lineno, + frame.lineno or -1, pycompat.sysstr(frame.function), ) ) @@ -954,7 +954,10 @@ ( ( '%s:%d' - % (simplifypath(pycompat.sysstr(frame.path)), frame.lineno), + % ( + simplifypath(pycompat.sysstr(frame.path)), + frame.lineno or -1, + ), pycompat.sysstr(frame.function), ) for frame in sample.stack