You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support binary, octal and hex values in argument conversion with int type #3909
If we have an argument like arg: int, we convert strings like 42 and -1 to integer. In some contexts it would be convenient to represent numbers using binary, octal or hexadecimal values. Because these values cannot be reliable separated from normal integers, we should require using the common 0b, 0o and 0x prefixes. For example, integer 170 could be represented as 0b10101010, 0o252 or 0xAA.
Notice that similar support was added to Convert To Integer and Should (Not) Be Equal As Integers (#808) and to number variables (e.g. ${0xAA), #835) already in RF 2.6. Once we enhance argument conversion like this (and don't need to support Python 2), we can simply add type hints to the aforementioned keywords to get conversion done automatically. Without this enhancement we'd need to keep the custom code in the aforementioned keywords.
The format should be space-insensitive to allow using e.g. 0b 1010 1010 and case-insensitive to support both 0xFF and 0xff. I'm not sure should we allow the prefix to be case-insensitive and allow both 0b10 and 0B10, but I think we do that elsewhere so for consistency reasons that would be good.
Activity
pekkaklarck commentedon Mar 26, 2021
The format should be space-insensitive to allow using e.g.
0b 1010 1010and case-insensitive to support both0xFFand0xff. I'm not sure should we allow the prefix to be case-insensitive and allow both0b10and0B10, but I think we do that elsewhere so for consistency reasons that would be good.