1. John Mulligan
  2. vanity

Commits

John Mulligan  committed 2bf99ff

extract frame check into function, usable by other modules

  • Participants
  • Parent commits df6804a
  • Branches default

Comments (0)

Files changed (1)

File vanity/commander.py

View file
  • Ignore whitespace
     return opts
 
 
+def firstframe():
+    """returns true if the type error was caused by the first
+    function call in the stack
+    """
+    return len(traceback.extract_tb(sys.exc_info()[2])) == 1
+
+
 class Command(object):
     """A thin class representing a command.
 
         try:
             return self.target(*args, **opts)
         except TypeError, err:
-            if len(traceback.extract_tb(sys.exc_info()[2])) == 1:
+            if firstframe():
                 raise InvalidArguments(self.name)
             raise