From 049ca4f7cade58056114124253a61f667cf779a4 Mon Sep 17 00:00:00 2001 From: Heewa Barfchin Date: Sun, 2 Nov 2014 19:38:36 -0500 Subject: [PATCH] Find real option definer. 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tornado/options.py b/tornado/options.py index 5e23e2910..c855407c2 100644 --- a/tornado/options.py +++ b/tornado/options.py @@ -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 = "" -- 2.47.2