diff -r 058f9a9f97cd Lib/test/test_tools.py --- a/Lib/test/test_tools.py Wed Apr 04 22:37:50 2012 -0400 +++ b/Lib/test/test_tools.py Fri Apr 06 11:12:59 2012 +0300 @@ -72,6 +72,16 @@ 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_gprof(self): + # Issue #14508: this used to fail with an NameError. + self.gprof.main() + + def test_main(): support.run_unittest(*[obj for obj in globals().values() if isinstance(obj, type)]) diff -r 058f9a9f97cd Tools/scripts/gprof2html.py --- a/Tools/scripts/gprof2html.py Wed Apr 04 22:37:50 2012 -0400 +++ b/Tools/scripts/gprof2html.py Fri Apr 06 11:12:59 2012 +0300 @@ -19,17 +19,19 @@ """ -def add_escapes(input): - for line in input: - yield cgi.escape(line) +def add_escapes(filename): + with open(filename): + for line in fp: + yield cgi.escape(line) + 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 によって変換されたページ (->オリジナル) /