Mercurial > public > mercurial-scm > hg
comparison mercurial/statprof.py @ 50305:972f3e5c94b8 stable
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.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 07 Mar 2023 17:13:38 +0100 |
parents | 9eb69fa5a783 |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50304:805d4a462abb | 50305:972f3e5c94b8 |
---|---|
538 % (b"time", b"seconds", b"seconds", b"name") | 538 % (b"time", b"seconds", b"seconds", b"name") |
539 ) | 539 ) |
540 | 540 |
541 for stat in stats: | 541 for stat in stats: |
542 site = stat.site | 542 site = stat.site |
543 sitelabel = b'%s:%d:%s' % (site.filename(), site.lineno, site.function) | 543 sitelabel = b'%s:%d:%s' % ( |
544 site.filename(), | |
545 site.lineno or -1, | |
546 site.function, | |
547 ) | |
544 fp.write( | 548 fp.write( |
545 b'%6.2f %9.2f %9.2f %s\n' | 549 b'%6.2f %9.2f %9.2f %s\n' |
546 % ( | 550 % ( |
547 stat.selfpercent(), | 551 stat.selfpercent(), |
548 stat.totalseconds(), | 552 stat.totalseconds(), |
611 source = pycompat.bytestr(source) | 615 source = pycompat.bytestr(source) |
612 | 616 |
613 stattuple = ( | 617 stattuple = ( |
614 stat.selfpercent(), | 618 stat.selfpercent(), |
615 stat.selfseconds(), | 619 stat.selfseconds(), |
616 stat.site.lineno, | 620 stat.site.lineno or -1, |
617 source, | 621 source, |
618 ) | 622 ) |
619 | 623 |
620 fp.write(b'%33.0f%% %6.2f line %d: %s\n' % stattuple) | 624 fp.write(b'%33.0f%% %6.2f line %d: %s\n' % stattuple) |
621 | 625 |