##// END OF EJS Templates
Fix profiler stats problem with python2.5
fperez -
Show More
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
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 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -1354,14 +1354,23 b' Currently the magic system has the following functions:\\n"""'
1354 except ValueError:
1354 except ValueError:
1355 lims.append(lim)
1355 lims.append(lim)
1356
1356
1357 # trap output
1357 # Trap output.
1358 sys_stdout = sys.stdout
1359 stdout_trap = StringIO()
1358 stdout_trap = StringIO()
1360 try:
1359
1361 sys.stdout = stdout_trap
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 stats.print_stats(*lims)
1364 stats.print_stats(*lims)
1363 finally:
1365 else:
1364 sys.stdout = sys_stdout
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 output = stdout_trap.getvalue()
1374 output = stdout_trap.getvalue()
1366 output = output.rstrip()
1375 output = output.rstrip()
1367
1376
@@ -1375,7 +1384,9 b' Currently the magic system has the following functions:\\n"""'
1375 print '\n*** Profile stats marshalled to file',\
1384 print '\n*** Profile stats marshalled to file',\
1376 `dump_file`+'.',sys_exit
1385 `dump_file`+'.',sys_exit
1377 if text_file:
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 print '\n*** Profile printout saved to text file',\
1390 print '\n*** Profile printout saved to text file',\
1380 `text_file`+'.',sys_exit
1391 `text_file`+'.',sys_exit
1381
1392
@@ -1,5 +1,9 b''
1 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
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 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
7 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
4 Pernetty's patch to improve support for (X)Emacs under Win32.
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