[pypy-svn] r10049 - pypy/dist/pypy/module/builtin
hpk at codespeak.net
hpk at codespeak.net
Tue Mar 22 02:55:32 CET 2005
Author: hpk
Date: Tue Mar 22 02:55:32 2005
New Revision: 10049
Modified:
pypy/dist/pypy/module/builtin/operation.py
Log:
hum, iter() is just fishy with respect to errors/type checking
Modified: pypy/dist/pypy/module/builtin/operation.py
==============================================================================
--- pypy/dist/pypy/module/builtin/operation.py (original)
+++ pypy/dist/pypy/module/builtin/operation.py Tue Mar 22 02:55:32 2005
@@ -91,18 +91,21 @@
def iter(space, w_collection_or_callable, w_sentinel=NoneNotWrapped):
if w_sentinel is None:
- w_res = space.iter(w_collection_or_callable)
- w_typeres = space.type(w_res)
- try:
- space.getattr(w_typeres, space.wrap('next'))
- except OperationError, e:
- if not e.match(space, space.w_AttributeError):
- raise
- raise OperationError(space.w_TypeError,
- space.wrap("iter() returned non-iterator of type '%s'" %
- w_typeres.name))
- else:
- return w_res
+ return space.iter(w_collection_or_callable)
+ # XXX it seems that CPython checks the following
+ # for newstyle but doesn't for oldstyle classes :-(
+ #w_res = space.iter(w_collection_or_callable)
+ #w_typeres = space.type(w_res)
+ #try:
+ # space.getattr(w_typeres, space.wrap('next'))
+ #except OperationError, e:
+ # if not e.match(space, space.w_AttributeError):
+ # raise
+ # raise OperationError(space.w_TypeError,
+ # space.wrap("iter() returned non-iterator of type '%s'" %
+ # w_typeres.name))
+ #else:
+ # return w_res
else:
return iter_sentinel(space, w_collection_or_callable, w_sentinel)
More information about the Pypy-commit
mailing list