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), ])