[Python-checkins] python/dist/src/Lib profile.py,1.51,1.52

mondragon at users.sourceforge.net mondragon at users.sourceforge.net
Mon Mar 22 15:12:57 EST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12193/Lib

Modified Files:
	profile.py 
Log Message:
Added global runctx function to profile to fix SF Bug #716587


Index: profile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** profile.py	12 Feb 2004 17:35:07 -0000	1.51
--- profile.py	22 Mar 2004 20:12:55 -0000	1.52
***************
*** 77,80 ****
--- 77,97 ----
          return prof.print_stats()
  
+ def runctx(statement, globals, locals, filename=None):
+     """Run statement under profiler, supplying your own globals and locals,
+     optionally saving results in filename.
+ 
+     statement and filename have the same semantics as profile.run
+     """
+     prof = Profile()
+     try:
+         prof = prof.runctx(statement, globals, locals)
+     except SystemExit:
+         pass
+ 
+     if filename is not None:
+         prof.dump_stats(filename)
+     else:
+         return prof.print_stats()
+ 
  # print help
  def help():




More information about the Python-checkins mailing list