From: Stefan Krah Date: Tue, 2 Aug 2016 20:30:24 +0000 (+0200) Subject: Issue #27241: Catch exception when running pstats as main. X-Git-Tag: v3.6.0a4~83^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e12a68be3580a3c7b80d384b2664b1921a7ff55b;p=python Issue #27241: Catch exception when running pstats as main. --- diff --git a/Lib/pstats.py b/Lib/pstats.py index e1ec355740..d861413d41 100644 --- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -574,7 +574,10 @@ if __name__ == '__main__': def do_add(self, line): 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: print("No statistics object is loaded.", file=self.stream) return 0