[PATCH 3 of 4 stable] statprof: with Python 3.12, lineno is (more) often None
Mads Kiilerich
mads at kiilerich.com
Tue Mar 7 18:23:18 UTC 2023
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1678205618 -3600
# Tue Mar 07 17:13:38 2023 +0100
# Branch stable
# Node ID 6ab12a75c936e0f1bf4305b9fdf9960219d1a39c
# Parent 72ba5a6dbb52570fbdfa07ce15ac6ad88e35f63c
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.
diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -540,7 +540,7 @@ def display_by_line(data, fp):
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 +613,7 @@ def display_by_method(data, fp):
stattuple = (
stat.selfpercent(),
stat.selfseconds(),
- stat.site.lineno,
+ stat.site.lineno or -1,
source,
)
More information about the Mercurial-devel
mailing list