[pypy-svn] r40046 - in pypy/branch/rope-branch2/pypy: config objspace/std
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Mar 7 20:59:26 CET 2007
Author: cfbolz
Date: Wed Mar 7 20:59:25 2007
New Revision: 40046
Modified:
pypy/branch/rope-branch2/pypy/config/pypyoption.py
pypy/branch/rope-branch2/pypy/objspace/std/ropeobject.py
pypy/branch/rope-branch2/pypy/objspace/std/stringtype.py
Log:
fix two embarassing problems, add georg's patch (thanks!)
Modified: pypy/branch/rope-branch2/pypy/config/pypyoption.py
==============================================================================
--- pypy/branch/rope-branch2/pypy/config/pypyoption.py (original)
+++ pypy/branch/rope-branch2/pypy/config/pypyoption.py Wed Mar 7 20:59:25 2007
@@ -128,7 +128,7 @@
default=False),
BoolOption("withprebuiltchar",
- "use prebuilt single-character string objects",
+ "use prebuilt single-character string objects"),
BoolOption("withrope", "use ropes as the string implementation",
default=False),
Modified: pypy/branch/rope-branch2/pypy/objspace/std/ropeobject.py
==============================================================================
--- pypy/branch/rope-branch2/pypy/objspace/std/ropeobject.py (original)
+++ pypy/branch/rope-branch2/pypy/objspace/std/ropeobject.py Wed Mar 7 20:59:25 2007
@@ -413,13 +413,10 @@
def _convert_idx_params(space, w_self, w_sub, w_start, w_end):
self = w_self._node
sub = w_sub._node
- w_len = space.wrap(self.length())
- w_start = slicetype.adapt_bound(space, w_start, w_len)
- w_end = slicetype.adapt_bound(space, w_end, w_len)
- start = space.int_w(w_start)
- end = space.int_w(w_end)
+ start = slicetype.adapt_bound(space, self.length(), w_start)
assert start >= 0
+ end = slicetype.adapt_bound(space, self.length(), w_end)
assert end >= 0
return (self, sub, start, end)
@@ -834,7 +831,12 @@
return space.newbool(rope.compare(n1, n2) >= 0)
def getitem__Rope_ANY(space, w_str, w_index):
- ival = space.int_w(w_index)
+ if not space.lookup(w_index, '__index__'):
+ raise OperationError(
+ space.w_TypeError,
+ space.wrap("string indices must be integers, not %s" %
+ space.type(w_index).getname(space, '?')))
+ ival = space.getindex_w(w_index, space.w_IndexError)
node = w_str._node
slen = node.length()
if ival < 0:
@@ -855,7 +857,7 @@
def mul_string_times(space, w_str, w_times):
try:
- mul = space.int_w(w_times)
+ mul = space.getindex_w(w_times, space.w_OverflowError)
except OperationError, e:
if e.match(space, space.w_TypeError):
raise FailedToImplement
Modified: pypy/branch/rope-branch2/pypy/objspace/std/stringtype.py
==============================================================================
--- pypy/branch/rope-branch2/pypy/objspace/std/stringtype.py (original)
+++ pypy/branch/rope-branch2/pypy/objspace/std/stringtype.py Wed Mar 7 20:59:25 2007
@@ -18,7 +18,7 @@
# only share the empty string
if len(s) == 0:
return W_StringObject.EMPTY
- if self.config.objspace.std.withrope:
+ if space.config.objspace.std.withrope:
from pypy.objspace.std.ropeobject import rope, W_RopeObject
return W_RopeObject(rope.LiteralStringNode(s))
return W_StringObject(s)
More information about the Pypy-commit
mailing list