diff options
author | Fadi Moukayed <smfadi@gmail.com> | 2015-08-06 14:07:25 +0200 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-10 10:54:10 +0900 |
commit | 45c14ec59be74546feed8eef73de9cb617cc614d (patch) | |
tree | 025d04942a9df665d2c8c17c16063249ccff1247 | |
parent | 3b4a82bab2f9d6ad444344dc2b3fcf81a57d4aa9 (diff) |
Python 3: Filter out None values returned by getmodule(...) to fix the stack inspection
Signed-off-by: Fadi Moukayed <smfadi@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/base/app_manager.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index 340d31a9..5b63e8cd 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -77,11 +77,12 @@ def require_app(app_name, api_style=False): If this is used for client application module, set api_style=False. """ + iterable = (inspect.getmodule(frame[0]) for frame in inspect.stack()) + modules = [module for module in iterable if module is not None] if api_style: - frm = inspect.stack()[2] # skip a frame for "api" module + m = modules[2] # skip a frame for "api" module else: - frm = inspect.stack()[1] - m = inspect.getmodule(frm[0]) # client module + m = modules[1] m._REQUIRED_APP = getattr(m, '_REQUIRED_APP', []) m._REQUIRED_APP.append(app_name) LOG.debug('require_app: %s is required by %s', app_name, m.__name__) |