Skip to content

Commit f9d400a

Browse files
committed
Move decorator import in debug.py closer to actual usage points so the
decorator library is not imported unless needed - it doesn't appear to be part of Python 2.7 so needs to be installed separately - Legacy-Id: 6765
1 parent 9457669 commit f9d400a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

debug.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
except ImportError:
2525
debug = True
2626

27-
from decorator import decorator
28-
2927
# A debug decorator, written by Paul Butler, taken from
3028
# http://paulbutler.org/archives/python-debugging-with-decorators/
3129
# Additional functions and decorator functionality added by
@@ -78,6 +76,7 @@ def wrap(fn, *params,**kwargs):
7876
return ret
7977
wrap.callcount = 0
8078
if debug:
79+
from decorator import decorator
8180
return decorator(wrap, fn)
8281
else:
8382
return fn
@@ -109,6 +108,7 @@ def wrap(fn, *params,**kwargs):
109108
return ret
110109
wrap.callcount = 0
111110
if debug:
111+
from decorator import decorator
112112
return decorator(wrap, fn)
113113
else:
114114
return fn
@@ -169,6 +169,7 @@ def wrapper(*args, **kwargs):
169169
prof.dump_stats(datafn)
170170
return retval
171171
if debug:
172+
from decorator import decorator
172173
return decorator(wrapper, fn)
173174
else:
174175
return fn

0 commit comments

Comments
 (0)