[pypy-commit] pypy py3k: merge default
pjenvey
noreply at buildbot.pypy.org
Sun Apr 28 00:03:52 CEST 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r63711:1d8fa565aa74
Date: 2013-04-27 15:03 -0700
http://bitbucket.org/pypy/pypy/changeset/1d8fa565aa74/
Log: merge default
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -370,7 +370,10 @@
if key in ffi._parser._declarations:
tp = ffi._parser._declarations[key]
BType = ffi._get_cached_btype(tp)
- value = backendlib.load_function(BType, name)
+ try:
+ value = backendlib.load_function(BType, name)
+ except KeyError:
+ raise AttributeError(name)
library.__dict__[name] = value
return
#
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_function.py b/pypy/module/test_lib_pypy/cffi_tests/test_function.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_function.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_function.py
@@ -333,3 +333,11 @@
assert lib.DD == 6
assert lib.EE == -5
assert lib.FF == -4
+
+ def test_missing_function(self):
+ ffi = FFI(backend=self.Backend())
+ ffi.cdef("""
+ int nonexistent();
+ """)
+ m = ffi.dlopen("m")
+ assert not hasattr(m, 'nonexistent')
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_verify.py b/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
@@ -8,7 +8,7 @@
if sys.platform == 'win32':
pass # no obvious -Werror equivalent on MSVC
elif (sys.platform == 'darwin' and
- map(int, os.uname()[2].split('.')) >= [11, 0, 0]):
+ [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
pass # recent MacOSX come with clang by default, and passing some
# flags from the interpreter (-mno-fused-madd) generates a
# warning --- which is interpreted as an error with -Werror
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -541,10 +541,13 @@
class __extend__(SomeString):
- def method_isdigit(chr):
+ def method_isdigit(str):
return s_Bool
- def method_isalpha(chr):
+ def method_isalpha(str):
+ return s_Bool
+
+ def method_isalnum(str):
return s_Bool
def method_upper(str):
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -259,6 +259,12 @@
hop.exception_cannot_occur()
return hop.gendirectcall(self.ll.ll_isalpha, v_str)
+ def rtype_method_isalnum(self, hop):
+ string_repr = hop.args_r[0].repr
+ [v_str] = hop.inputargs(string_repr)
+ hop.exception_cannot_occur()
+ return hop.gendirectcall(self.ll.ll_isalnum, v_str)
+
def _list_length_items(self, hop, v_lst, LIST):
"""Return two Variables containing the length and items of a
list. Need to be overriden because it is typesystem-specific."""
@@ -779,6 +785,17 @@
return False
return True
+ def ll_isalnum(s):
+ from rpython.rtyper.annlowlevel import hlstr
+
+ s = hlstr(s)
+ if not s:
+ return False
+ for ch in s:
+ if not ch.isalnum():
+ return False
+ return True
+
def ll_char_isspace(ch):
c = ord(ch)
return c == 32 or (9 <= c <= 13) # c in (9, 10, 11, 12, 13, 32)
diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -156,6 +156,15 @@
for i in xrange(3):
assert self.interpret(fn, [i]) == fn(i)
+ def test_str_isalnum(self):
+ const = self.const
+
+ def fn(i):
+ consts = [const(''), const('abc'), const('abc123'), const('abc123!')]
+ return consts[i].isalnum()
+ for i in xrange(3):
+ assert self.interpret(fn, [i]) == fn(i)
+
def test_char_compare(self):
const = self.const
res = self.interpret(lambda c1, c2: c1 == c2, [const('a'),
More information about the pypy-commit
mailing list