DebugClients/Python/PyProfile.py

branch
debugger speed
changeset 5179
5f56410e7624
parent 5178
878ce843ca9f
child 5389
9b1c800daff3
--- a/DebugClients/Python/PyProfile.py	Mon Sep 19 22:47:52 2016 +0200
+++ b/DebugClients/Python/PyProfile.py	Sat Sep 24 22:52:13 2016 +0200
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2009 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2002 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
 
 """
 Module defining additions to the standard Python profile.py.
@@ -11,6 +11,7 @@
 import profile
 import atexit
 import pickle
+import sys
 
 
 class PyProfile(profile.Profile):
@@ -30,7 +31,10 @@
         @param timer function defining the timing calculation
         @param bias calibration value (float)
         """
-        profile.Profile.__init__(self, timer, bias)
+        try:
+            profile.Profile.__init__(self, timer, bias)
+        except TypeError:
+            profile.Profile.__init__(self, timer)
         
         self.dispatch = self.__class__.dispatch
         
@@ -115,16 +119,21 @@
         @param frame the frame object
         @return fixed up file name (string)
         """
+        if sys.version_info[0] == 2:
+            versionExt = '.py2'
+        else:
+            versionExt = '.py3'
+        
         # get module name from __file__
         if not isinstance(frame, profile.Profile.fake_frame) and \
                 '__file__' in frame.f_globals:
             root, ext = os.path.splitext(frame.f_globals['__file__'])
-            if ext in ['.pyc', '.py', '.py3', '.pyo']:
+            if ext in ['.pyc', '.py', versionExt, '.pyo']:
                 fixedName = root + '.py'
                 if os.path.exists(fixedName):
                     return fixedName
                 
-                fixedName = root + '.py3'
+                fixedName = root + versionExt
                 if os.path.exists(fixedName):
                     return fixedName
 

eric ide

mercurial