statprof: with Python 3.12, lineno is (more) often None
test-profile.t failed with errors like:
TypeError: %d format: a real number is required, not NoneType
statprof.py already handled None values as -1 in some cases. Do the same in
more cases.
--- a/mercurial/statprof.py Tue Mar 07 16:45:54 2023 +0100
+++ b/mercurial/statprof.py Tue Mar 07 17:13:38 2023 +0100
@@ -540,7 +540,11 @@
for stat in stats:
site = stat.site
- sitelabel = b'%s:%d:%s' % (site.filename(), site.lineno, site.function)
+ sitelabel = b'%s:%d:%s' % (
+ site.filename(),
+ site.lineno or -1,
+ site.function,
+ )
fp.write(
b'%6.2f %9.2f %9.2f %s\n'
% (
@@ -613,7 +617,7 @@
stattuple = (
stat.selfpercent(),
stat.selfseconds(),
- stat.site.lineno,
+ stat.site.lineno or -1,
source,
)