aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/panels/profiling.py8
-rw-r--r--debug_toolbar/panels/signals.py6
-rw-r--r--debug_toolbar/utils/tracking/__init__.py6
3 files changed, 10 insertions, 10 deletions
diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py
index f71472b..995cccb 100644
--- a/debug_toolbar/panels/profiling.py
+++ b/debug_toolbar/panels/profiling.py
@@ -155,12 +155,12 @@ class ProfilingDebugPanel(DebugPanel):
return _('Profiling')
def _unwrap_closure_and_profile(self, func):
- if not hasattr(func, 'func_code'):
+ if not hasattr(func, '__code__'):
return
self.line_profiler.add_function(func)
- if func.func_closure:
- for cell in func.func_closure:
- if hasattr(cell.cell_contents, 'func_code'):
+ if func.__closure__:
+ for cell in func.__closure__:
+ if hasattr(cell.cell_contents, '__code__'):
self._unwrap_closure_and_profile(cell.cell_contents)
def process_view(self, request, view_func, view_args, view_kwargs):
diff --git a/debug_toolbar/panels/signals.py b/debug_toolbar/panels/signals.py
index d6a5b2e..d3d9cfc 100644
--- a/debug_toolbar/panels/signals.py
+++ b/debug_toolbar/panels/signals.py
@@ -89,9 +89,9 @@ class SignalDebugPanel(DebugPanel):
receiver = getattr(receiver, '__wraps__', receiver)
receiver_name = getattr(receiver, '__name__', str(receiver))
- if getattr(receiver, 'im_self', None) is not None:
- text = "%s.%s" % (getattr(receiver.im_self, '__class__', type).__name__, receiver_name)
- elif getattr(receiver, 'im_class', None) is not None:
+ if getattr(receiver, '__self__', None) is not None:
+ text = "%s.%s" % (getattr(receiver.__self__, '__class__', type).__name__, receiver_name)
+ elif getattr(receiver, 'im_class', None) is not None: # Python 2 only
text = "%s.%s" % (receiver.im_class.__name__, receiver_name)
else:
text = "%s" % receiver_name
diff --git a/debug_toolbar/utils/tracking/__init__.py b/debug_toolbar/utils/tracking/__init__.py
index ac00f4c..4fbefa5 100644
--- a/debug_toolbar/utils/tracking/__init__.py
+++ b/debug_toolbar/utils/tracking/__init__.py
@@ -52,10 +52,10 @@ def _replace_function(func, wrapped):
else:
module = import_module(func.__module__)
setattr(module, func.__name__, wrapped)
- elif getattr(func, 'im_self', None):
- setattr(func.im_self, func.__name__, classmethod(wrapped))
+ elif getattr(func, '__self__', None):
+ setattr(func.__self__, func.__name__, classmethod(wrapped))
elif hasattr(func, 'im_class'):
- # for unbound methods
+ # for unbound methods - Python 2 only
setattr(func.im_class, func.__name__, wrapped)
else:
raise NotImplementedError