]> granicus.if.org Git - python/commitdiff
Issue #27241: Catch exception when running pstats as main.
authorStefan Krah <skrah@bytereef.org>
Tue, 2 Aug 2016 20:30:24 +0000 (22:30 +0200)
committerStefan Krah <skrah@bytereef.org>
Tue, 2 Aug 2016 20:30:24 +0000 (22:30 +0200)
Lib/pstats.py

index e1ec355740672ad539b7c10bc0615e7b0b5b3802..d861413d4195f726ae6e67542c5479ee12f9f966 100644 (file)
@@ -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