fix traceback depth determining when command doesn't get expected arguments
authorAlexander Solovyov <alexander@solovyov.net>
Sun, 23 Jan 2011 22:10:02 +0100
changeset 167 8c750909fe8d
parent 166 ac27c99de716
child 168 9287894e542f
fix traceback depth determining when command doesn't get expected arguments
opster.py
--- a/opster.py	Sun Jan 23 18:42:41 2011 +0100
+++ b/opster.py	Sun Jan 23 22:10:02 2011 +0100
@@ -151,8 +151,9 @@
     if name == '_completion':       # skip middleware
         worker = lambda: call_cmd(name, func)(*args, **kwargs)
     else:
-        worker = lambda: (call_cmd(name, middleware(func), depth=2)
-                          (*args, **kwargs))
+        mwfunc = middleware(func)
+        depth = func == mwfunc and 1 or 2
+        worker = lambda: call_cmd(name, mwfunc, depth=depth)(*args, **kwargs)
 
     try:
         return catcher(worker, help_func)