Issue #27241: Catch exception when running pstats as main.

This commit is contained in:
Stefan Krah 2016-08-02 22:30:24 +02:00
parent 7bfbd1d3c5
commit e12a68be35
1 changed files with 4 additions and 1 deletions

View File

@ -574,7 +574,10 @@ if __name__ == '__main__':
def do_add(self, line): def do_add(self, line):
if self.stats: if self.stats:
self.stats.add(line) try:
self.stats.add(line)
except IOError as e:
print("Failed to load statistics for %s: %s" % (line, e), file=self.stream)
else: else:
print("No statistics object is loaded.", file=self.stream) print("No statistics object is loaded.", file=self.stream)
return 0 return 0