]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Find real option definer. 1241/head
authorHeewa Barfchin <heewa.b@gmail.com>
Mon, 3 Nov 2014 00:38:36 +0000 (19:38 -0500)
committerHeewa Barfchin <heewa.b@gmail.com>
Mon, 3 Nov 2014 00:38:36 +0000 (19:38 -0500)
When an option is defined through the module level "define" fn, not
directly through the class method, we should look one frame up to
find the real caller.

tornado/options.py

index 5e23e2910408c8d0483dec4d52fde503a96388a2..c855407c295ea475f864eae9497402192aa24a14 100644 (file)
@@ -204,6 +204,13 @@ class OptionParser(object):
                         (name, self._options[name].file_name))
         frame = sys._getframe(0)
         options_file = frame.f_code.co_filename
+
+        # Can be called directly, or through top level define() fn, in which
+        # case, step up above that frame to look for real caller.
+        if (frame.f_back.f_code.co_filename == options_file and
+                frame.f_back.f_code.co_name == 'define'):
+            frame = frame.f_back
+
         file_name = frame.f_back.f_code.co_filename
         if file_name == options_file:
             file_name = ""