Author: Manuel Jacob <[email protected]>
Branch: py3.5
Changeset: r90470:e761f5e9359b
Date: 2017-03-02 11:38 +0100
http://bitbucket.org/pypy/pypy/changeset/e761f5e9359b/
Log: hg merge default
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -575,7 +575,7 @@
return space.w_NotImplemented
if not space.eq_w(self.w_instance, w_other.w_instance):
return space.w_False
- return space.eq(self.w_function, w_other.w_function)
+ return space.newbool(space.eq_w(self.w_function, w_other.w_function))
def is_w(self, space, other):
if not isinstance(other, Method):
diff --git a/pypy/interpreter/test/test_function.py
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -574,6 +574,18 @@
assert A().m == X()
assert X() == A().m
+ def test_method_equals_with_identity(self):
+ from types import MethodType
+ class CallableBadEq(object):
+ def __call__(self):
+ pass
+ def __eq__(self, other):
+ raise ZeroDivisionError
+ func = CallableBadEq()
+ meth = MethodType(func, object)
+ assert meth == meth
+ assert meth == MethodType(func, object)
+
@pytest.mark.skipif("config.option.runappdirect")
def test_method_identity(self):
class A(object):
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -881,7 +881,7 @@
if whence == 1:
# seek relative to current position
- if not space.is_true(space.eq(w_pos, space.newint(0))):
+ if not space.eq_w(w_pos, space.newint(0)):
self._unsupportedoperation(
space, "can't do nonzero cur-relative seeks")
# Seeking to the current position should attempt to sync the
@@ -890,7 +890,7 @@
elif whence == 2:
# seek relative to end of file
- if not space.is_true(space.eq(w_pos, space.newint(0))):
+ if not space.eq_w(w_pos, space.newint(0)):
self._unsupportedoperation(
space, "can't do nonzero end-relative seeks")
space.call_method(self, "flush")
diff --git a/pypy/module/array/interp_array.py
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -95,7 +95,7 @@
w_elem1 = arr1.w_getitem(space, i)
w_elem2 = arr2.w_getitem(space, i)
if comp_op == EQ:
- res = space.is_true(space.eq(w_elem1, w_elem2))
+ res = space.eq_w(w_elem1, w_elem2)
if not res:
return space.w_False
elif comp_op == NE:
@@ -109,7 +109,7 @@
res = space.is_true(space.gt(w_elem1, w_elem2))
if res:
return space.w_True
- elif not space.is_true(space.eq(w_elem1, w_elem2)):
+ elif not space.eq_w(w_elem1, w_elem2):
return space.w_False
else:
if comp_op == LE:
@@ -118,7 +118,7 @@
res = space.is_true(space.ge(w_elem1, w_elem2))
if not res:
return space.w_False
- elif not space.is_true(space.eq(w_elem1, w_elem2)):
+ elif not space.eq_w(w_elem1, w_elem2):
return space.w_True
# we have some leftovers
if comp_op == EQ:
@@ -282,7 +282,7 @@
for i in range(self.len):
# XXX jitdriver
w_item = self.w_getitem(space, i)
- if space.is_true(space.eq(w_item, w_val)):
+ if space.eq_w(w_item, w_val):
cnt += 1
return space.newint(cnt)
@@ -293,7 +293,7 @@
"""
for i in range(self.len):
w_item = self.w_getitem(space, i)
- if space.is_true(space.eq(w_item, w_x)):
+ if space.eq_w(w_item, w_x):
return space.newint(i)
raise oefmt(space.w_ValueError, "array.index(x): x not in list")
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -230,7 +230,7 @@
if e.match(space, space.w_StopIteration):
break
raise
- if space.is_true(space.eq(w_next, w_obj)):
+ if space.eq_w(w_next, w_obj):
return idx
idx += 1
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1549,7 +1549,7 @@
w_found = self.w_dict.getitem(w_key)
if w_found is None:
return space.w_False
- return space.eq(w_value, w_found)
+ return space.newbool(space.eq_w(w_value, w_found))
class W_DictViewKeysObject(W_DictViewObject, SetLikeDictView):
def descr_iter(self, space):
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -813,6 +813,14 @@
e["a"] = "def"
assert d.items() != e.items()
+ def test_dict_items_contains_with_identity(self):
+ class BadEq(object):
+ def __eq__(self, other):
+ raise ZeroDivisionError
+ k = BadEq()
+ v = BadEq()
+ assert (k, v) in {k: v}.viewitems()
+
def test_dict_mixed_keys_items(self):
d = {(1, 1): 11, (2, 2): 22}
e = {1: 1, 2: 2}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit