From 90b7daebb69dd2d56ccdc5ca1e98836a2cafc30e Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sat, 28 Oct 2017 11:18:23 +0330 Subject: [PATCH] Fix invalid auto_int value error when --umask=0 passed (#1632) Fixes #1622 --- gunicorn/config.py | 4 ++-- tests/test_config.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gunicorn/config.py b/gunicorn/config.py index c8f8f16d..c36d0403 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -43,8 +43,8 @@ def make_settings(ignore=None): def auto_int(_, x): - if x.startswith('0') and not x.lower().startswith('0x'): - # for compatible with octal numbers in python3 + # for compatible with octal numbers in python3 + if re.match(r'0(\d)', x, re.IGNORECASE): x = x.replace('0', '0o', 1) return int(x, 0) diff --git a/tests/test_config.py b/tests/test_config.py index 28d470fa..714d2926 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -374,7 +374,9 @@ def test_reload(options, expected): @pytest.mark.parametrize("options, expected", [ - (["--umask 0", "myapp:app"], 0), + (["--umask", "0", "myapp:app"], 0), + (["--umask", "0o0", "myapp:app"], 0), + (["--umask", "0x0", "myapp:app"], 0), (["--umask", "0xFF", "myapp:app"], 255), (["--umask", "0022", "myapp:app"], 18), ])