From 395d85a12f9b2be24dce112a6a4b0e873374de7f Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Mon, 26 Jun 2017 21:26:34 -0700 Subject: [PATCH] use try/except --- sanic/config.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sanic/config.py b/sanic/config.py index ec4f9bf3..f5649cfe 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -201,11 +201,10 @@ class Config(dict): for k, v in os.environ.items(): if k.startswith(SANIC_PREFIX): _, config_key = k.split(SANIC_PREFIX, 1) - # This is a float or an int - if v.replace('.', '').isdigit(): - if '.' in v: + try: + self[config_key] = int(v) + except ValueError: + try: self[config_key] = float(v) - else: - self[config_key] = int(v) - else: - self[config_key] = v + except ValueError: + self[config_key] = v