mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipalib.parameters: Handle 0-prefixed octal format of ints
In Python 2, numbers prfixed with '0' are parsed as octal, e.g. '020' -> 16. In Python 3, the prefix is '0o'. Handle the old syntax for IPA's parameter conversion to keep backwards compatibility. Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
committed by
Tomas Babej
parent
c44dd40b26
commit
e0eff8b834
@@ -1072,6 +1072,9 @@ class Int(Number):
|
||||
if type(value) is unicode:
|
||||
if u'.' in value:
|
||||
return int(float(value))
|
||||
if six.PY3 and re.match('0[0-9]+', value):
|
||||
# 0-prefixed octal format
|
||||
return int(value, 8)
|
||||
return int(value, 0)
|
||||
|
||||
raise ValueError(value)
|
||||
|
||||
Reference in New Issue
Block a user