From 783c9bee3e761d9ecf5a820c3d9cce3ebb09a085 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Sun, 29 Oct 2017 21:44:10 -0700 Subject: [PATCH] Warn on Python < 2.7 for dictConfig --- gunicorn/glogging.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index bac945b1..f5d4cfd0 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -231,10 +231,22 @@ class Logger(object): self.access_log, cfg, self.syslog_fmt, "access" ) + if dictConfig is None and cfg.logconfig_dict: + util.warn("Dictionary-based log configuration requires " + "Python 2.7 or above.") + if dictConfig and cfg.logconfig_dict: config = CONFIG_DEFAULTS.copy() config.update(cfg.logconfig_dict) - dictConfig(config) + try: + dictConfig(config) + except ( + AttributeError, + ImportError, + ValueError, + TypeError + ) as exc: + raise RuntimeError(str(exc)) elif cfg.logconfig: if os.path.exists(cfg.logconfig): defaults = CONFIG_DEFAULTS.copy()