Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e12a68b

Browse files
author
Stefan Krah
committed
Issue #27241: Catch exception when running pstats as main.
1 parent 7bfbd1d commit e12a68b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/pstats.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,10 @@ def generic_help(self):
574574

575575
def do_add(self, line):
576576
if self.stats:
577-
self.stats.add(line)
577+
try:
578+
self.stats.add(line)
579+
except IOError as e:
580+
print("Failed to load statistics for %s: %s" % (line, e), file=self.stream)
578581
else:
579582
print("No statistics object is loaded.", file=self.stream)
580583
return 0

0 commit comments

Comments
 (0)