[pypy-commit] cffi default: remove useless try/catch, and remove unreachable elif statement.

guil...@Guillaumes-MacBook-Pro.local pypy.commits at gmail.com
Wed Mar 27 06:45:22 EDT 2019


Author: guillaumesottas at Guillaumes-MacBook-Pro.local
Branch: 
Changeset: r3250:ae7712fab365
Date: 2019-03-26 17:12 -0600
http://bitbucket.org/cffi/cffi/changeset/ae7712fab365/

Log:	remove useless try/catch, and remove unreachable elif statement.

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -833,8 +833,6 @@
                         elif s.lower()[0:2] == '0b':
                             return int(s, 2)
                 raise CDefError("invalid constant %r" % (s,))
-            elif '1' <= s[0] <= '9':
-                return int(s, 10)
             elif s[0] == "'" and s[-1] == "'" and (
                     len(s) == 3 or (len(s) == 4 and s[1] == "\\")):
                 return ord(s[-2])
diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -502,7 +502,4 @@
     C = ffi.dlopen(None)
     for base, expected_result in (('bin', 2), ('oct', 8), ('dec', 10), ('hex', 16)):
         for index in range(7):
-            try:
-                assert getattr(C, '{base}_{index}'.format(base=base, index=index)) == expected_result
-            except AssertionError as e:
-                raise e
+            assert getattr(C, '{base}_{index}'.format(base=base, index=index)) == expected_result


More information about the pypy-commit mailing list