From ef79ee3983cb1baa9484b2b3cc078b4faf6cfbbe Mon Sep 17 00:00:00 2001 From: Hasan Ramezni Date: Sun, 19 Feb 2017 11:50:50 +0330 Subject: [PATCH] fix non-decimal values problem in `umask` config.(issue 1325) --- gunicorn/config.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gunicorn/config.py b/gunicorn/config.py index 37e022ca..b64869c1 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -48,6 +48,13 @@ def make_settings(ignore=None): return settings +def auto_int(_, x): + if x.startswith('0') and not x.lower().startswith('0x'): + # for compatible with octal numbers in python3 + x = x.replace('0', '0o', 1) + return int(x, 0) + + class Config(object): def __init__(self, usage=None, prog=None): @@ -1043,14 +1050,13 @@ class Group(Setting): change the worker processes group. """ - class Umask(Setting): name = "umask" section = "Server Mechanics" cli = ["-m", "--umask"] meta = "INT" validator = validate_pos_int - type = int + type = auto_int default = 0 desc = """\ A bit mask for the file mode on files written by Gunicorn.