[pypy-commit] pypy flow-no-local-exception: Fix some modules
arigo
noreply at buildbot.pypy.org
Thu Aug 8 12:36:48 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: flow-no-local-exception
Changeset: r66012:71ef9d6bba05
Date: 2013-08-08 12:35 +0200
http://bitbucket.org/pypy/pypy/changeset/71ef9d6bba05/
Log: Fix some modules
diff --git a/pypy/module/binascii/interp_uu.py b/pypy/module/binascii/interp_uu.py
--- a/pypy/module/binascii/interp_uu.py
+++ b/pypy/module/binascii/interp_uu.py
@@ -5,10 +5,9 @@
# ____________________________________________________________
def _a2b_read(space, s, index):
- try:
- c = s[index]
- except IndexError:
+ if index >= len(s):
return 0
+ c = s[index]
# Check the character for legality. The 64 instead of the expected 63
# is because there are a few uuencodes out there that use '`' as zero
# instead of space.
@@ -57,11 +56,10 @@
# ____________________________________________________________
def _b2a_read(bin, i):
- try:
- return ord(bin[i])
- except IndexError:
+ if i >= len(bin):
return 0
-_a2b_read._always_inline_ = True
+ return ord(bin[i])
+_b2a_read._always_inline_ = True
@unwrap_spec(bin='bufferstr')
def b2a_uu(space, bin):
diff --git a/pypy/module/itertools/interp_itertools.py b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -691,37 +691,33 @@
self.space = space
self.saved_w = []
self.w_iterable = space.iter(w_iterable)
- self.index = 0
- self.exhausted = False
+ self.index = -1 # during the first run; if >= 0, we are repeating
def iter_w(self):
return self.space.wrap(self)
def next_w(self):
- if self.exhausted:
- if not self.saved_w:
- raise OperationError(self.space.w_StopIteration, self.space.w_None)
- try:
- w_obj = self.saved_w[self.index]
- except IndexError:
- self.index = 1
- w_obj = self.saved_w[0]
- else:
- self.index += 1
+ index = self.index
+ if index >= 0: # if we are repeating
+ if index >= len(self.saved_w):
+ index = 0
+ if len(self.saved_w) == 0:
+ raise OperationError(self.space.w_StopIteration,
+ self.space.w_None)
+ self.index = index + 1
+ w_obj = self.saved_w[index]
else:
try:
w_obj = self.space.next(self.w_iterable)
except OperationError, e:
if e.match(self.space, self.space.w_StopIteration):
- self.exhausted = True
+ self.index = 1 # exhausted
if not self.saved_w:
raise
- self.index = 1
w_obj = self.saved_w[0]
else:
raise
else:
- self.index += 1
self.saved_w.append(w_obj)
return w_obj
More information about the pypy-commit
mailing list