Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(import_app): print original exception on AppImportError #1334

Merged
merged 4 commits into from Oct 3, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion gunicorn/util.py
Expand Up @@ -387,6 +387,8 @@ def import_app(module):
try:
app = eval(obj, mod.__dict__)
except NameError:
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_exception(exc_type, exc_value, exc_traceback)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should only be done when debug mode is enabled. If not it can expose some unwanted to externals systems looking at the output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By debug mode, do you mean checking the logging level ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptbrowne yes :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please either use star args to avoid locals or explicitly delete the traceback. See #1228.

raise AppImportError("Failed to find application: %r" % module)

if app is None:
Expand Down Expand Up @@ -565,4 +567,4 @@ def app(environ, start_response):
])
return [msg]

return app
return app