diff -r 64b8fdb0bfa9 Lib/test/test_tools.py --- a/Lib/test/test_tools.py Thu Apr 05 06:42:48 2012 +0300 +++ b/Lib/test/test_tools.py Thu Apr 05 15:59:54 2012 +0300 @@ -6,6 +6,7 @@ import os import sys +import imp import unittest import sysconfig from test import support @@ -72,6 +73,21 @@ import analyze_dxp +class GprofHtmlTests(unittest.TestCase): + def setUp(self): + path = os.path.join(scriptsdir, 'gprof2html.py') + self.gprof = imp.load_source('gprof2html', path) + + def test_name_error(self): + try: + self.gprof.main() + except NameError: + self.fail("gprof2html fails with NameError") + except Exception: + pass + diff -r 64b8fdb0bfa9 Tools/scripts/gprof2html.py --- a/Tools/scripts/gprof2html.py Thu Apr 05 06:42:48 2012 +0300 +++ b/Tools/scripts/gprof2html.py Thu Apr 05 16:00:07 2012 +0300 @@ -19,17 +19,19 @@ """ -def add_escapes(input): - for line in input: +def add_escapes(filename): + fp = open(filename) + for line in fp: yield cgi.escape(line) + fp.close() def main(): filename = "gprof.out" if sys.argv[1:]: filename = sys.argv[1] outputfilename = filename + ".html" - input = add_escapes(file(filename)) - output = file(outputfilename, "w") + input = add_escapes(filename) + output = open(outputfilename, "w") output.write(header % filename) for line in input: output.write(line)

AltStyle によって変換されたページ (->オリジナル) /