From 5a25144807122b3905282beeca95c243ed063d07 Mon Sep 17 00:00:00 2001 From: guillaumesottas Date: Tue, 26 Mar 2019 17:23:50 -0600 Subject: remove extra comments. --- cffi/cparser.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'cffi') diff --git a/cffi/cparser.py b/cffi/cparser.py index d794139..262fd76 100644 --- a/cffi/cparser.py +++ b/cffi/cparser.py @@ -818,15 +818,13 @@ class Parser(object): if isinstance(exprnode, pycparser.c_ast.Constant): s = exprnode.value if '0' <= s[0] <= '9': - s = s.rstrip('uUlL') # remove integer constant suffix if any. this will remove pattern such as lL, but - # it is the responsibility of the C parser to perform this check. - try: # first we try to convert to base 8/10, as it will fail if the string contains base 2/16 C prefix. + s = s.rstrip('uUlL') + try: if s.startswith('0'): return int(s, 8) else: return int(s, 10) - except ValueError: # then it should be a base 2 or a base 16. it is necessary to explicitly check the - # prefix, as python's int() function will be able to convert both (0b01 and 0x0b01) into base 16. + except ValueError: if len(s) > 1: if s.lower()[0:2] == '0x': return int(s, 16) -- cgit v1.2.1