summaryrefslogtreecommitdiff
path: root/cffi
diff options
context:
space:
mode:
authorguillaumesottas <guillaumesottas@Guillaumes-MacBook-Pro.local>2019-03-26 17:23:50 -0600
committerguillaumesottas <guillaumesottas@Guillaumes-MacBook-Pro.local>2019-03-26 17:23:50 -0600
commit5a25144807122b3905282beeca95c243ed063d07 (patch)
tree1987e56721dff500b6dbd6dfdf629df7a936795c /cffi
parent32db187887a1e6966cdf971b3f9496d71a645a69 (diff)
downloadcffi-5a25144807122b3905282beeca95c243ed063d07.tar.gz
remove extra comments.
Diffstat (limited to 'cffi')
-rw-r--r--cffi/cparser.py8
1 files changed, 3 insertions, 5 deletions
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)