##// END OF EJS Templates
Fix profiler stats problem with python2.5
fperez -
r551:33e5f85f
parent child
Show More
@@ -1,7 +1,7
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 2122 2007-03-01 02:27:11Z fperez $"""
4 $Id: Magic.py 2153 2007-03-18 22:53:18Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -1354,14 +1354,23 Currently the magic system has the following functions:\n"""
1354 1354 except ValueError:
1355 1355 lims.append(lim)
1356 1356
1357 # trap output
1358 sys_stdout = sys.stdout
1357 # Trap output.
1359 1358 stdout_trap = StringIO()
1360 try:
1361 sys.stdout = stdout_trap
1359
1360 if hasattr(stats,'stream'):
1361 # In newer versions of python, the stats object has a 'stream'
1362 # attribute to write into.
1363 stats.stream = stdout_trap
1362 1364 stats.print_stats(*lims)
1363 finally:
1364 sys.stdout = sys_stdout
1365 else:
1366 # For older versions, we manually redirect stdout during printing
1367 sys_stdout = sys.stdout
1368 try:
1369 sys.stdout = stdout_trap
1370 stats.print_stats(*lims)
1371 finally:
1372 sys.stdout = sys_stdout
1373
1365 1374 output = stdout_trap.getvalue()
1366 1375 output = output.rstrip()
1367 1376
@@ -1375,7 +1384,9 Currently the magic system has the following functions:\n"""
1375 1384 print '\n*** Profile stats marshalled to file',\
1376 1385 `dump_file`+'.',sys_exit
1377 1386 if text_file:
1378 file(text_file,'w').write(output)
1387 pfile = file(text_file,'w')
1388 pfile.write(output)
1389 pfile.close()
1379 1390 print '\n*** Profile printout saved to text file',\
1380 1391 `text_file`+'.',sys_exit
1381 1392
@@ -1,5 +1,9
1 1 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
2 2
3 * IPython/Magic.py (magic_prun): Fix saving of profile info for
4 Python 2.5, where the stats object API changed a little. Thanks
5 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
6
3 7 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
4 8 Pernetty's patch to improve support for (X)Emacs under Win32.
5 9
General Comments 0
You need to be logged in to leave comments. Login now