Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r66359:1f16bf23eaf0
Date: 2013-08-27 15:38 +0100
http://bitbucket.org/pypy/pypy/changeset/1f16bf23eaf0/
Log: Fix.
diff --git a/pypy/objspace/std/bytearrayobject.py
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -236,6 +236,54 @@
def descr_str(self, space):
return space.wrap(''.join(self.data))
+ def descr_eq(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) == self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_ne(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) != self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_lt(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) < self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_le(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) <= self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_gt(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) > self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_ge(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) >= self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
def descr_buffer(self, space):
return BytearrayBuffer(self.data)
diff --git a/pypy/objspace/std/stringmethods.py
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -24,64 +24,6 @@
space, lenself, w_start, w_end, upper_bound=upper_bound)
return (value, start, end)
- def descr_eq(self, space, w_other):
- try:
- return space.newbool(self._val(space) == self._op_val(space,
w_other))
- except OperationError, e:
- if e.match(space, space.w_TypeError):
- return space.w_NotImplemented
- if (e.match(space, space.w_UnicodeDecodeError) or
- e.match(space, space.w_UnicodeEncodeError)):
- msg = ("Unicode equal comparison failed to convert both "
- "arguments to Unicode - interpreting them as being "
- "unequal")
- space.warn(space.wrap(msg), space.w_UnicodeWarning)
- return space.w_False
- raise
-
- def descr_ne(self, space, w_other):
- try:
- return space.newbool(self._val(space) != self._op_val(space,
w_other))
- except OperationError, e:
- if e.match(space, space.w_TypeError):
- return space.w_NotImplemented
- if (e.match(space, space.w_UnicodeDecodeError) or
- e.match(space, space.w_UnicodeEncodeError)):
- msg = ("Unicode unequal comparison failed to convert both "
- "arguments to Unicode - interpreting them as being "
- "unequal")
- space.warn(space.wrap(msg), space.w_UnicodeWarning)
- return space.w_True
- raise
-
- def descr_lt(self, space, w_other):
- try:
- return space.newbool(self._val(space) < self._op_val(space,
w_other))
- except OperationError, e:
- if e.match(space, space.w_TypeError):
- return space.w_NotImplemented
-
- def descr_le(self, space, w_other):
- try:
- return space.newbool(self._val(space) <= self._op_val(space,
w_other))
- except OperationError, e:
- if e.match(space, space.w_TypeError):
- return space.w_NotImplemented
-
- def descr_gt(self, space, w_other):
- try:
- return space.newbool(self._val(space) > self._op_val(space,
w_other))
- except OperationError, e:
- if e.match(space, space.w_TypeError):
- return space.w_NotImplemented
-
- def descr_ge(self, space, w_other):
- try:
- return space.newbool(self._val(space) >= self._op_val(space,
w_other))
- except OperationError, e:
- if e.match(space, space.w_TypeError):
- return space.w_NotImplemented
-
def descr_len(self, space):
return space.wrap(self._len())
diff --git a/pypy/objspace/std/unicodeobject.py
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -190,6 +190,68 @@
x = compute_hash(self._value)
return space.wrap(x)
+ def descr_eq(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) == self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ if (e.match(space, space.w_UnicodeDecodeError) or
+ e.match(space, space.w_UnicodeEncodeError)):
+ msg = ("Unicode equal comparison failed to convert both "
+ "arguments to Unicode - interpreting them as being "
+ "unequal")
+ space.warn(space.wrap(msg), space.w_UnicodeWarning)
+ return space.w_False
+ raise
+
+ def descr_ne(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) != self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ if (e.match(space, space.w_UnicodeDecodeError) or
+ e.match(space, space.w_UnicodeEncodeError)):
+ msg = ("Unicode unequal comparison failed to convert both "
+ "arguments to Unicode - interpreting them as being "
+ "unequal")
+ space.warn(space.wrap(msg), space.w_UnicodeWarning)
+ return space.w_True
+ raise
+
+ def descr_lt(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) < self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_le(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) <= self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_gt(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) > self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
+ def descr_ge(self, space, w_other):
+ try:
+ return space.newbool(self._val(space) >= self._op_val(space,
w_other))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+
def descr_format(self, space, __args__):
return newformat.format_method(space, self, __args__, is_unicode=True)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit