Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3k-update Changeset: r84048:7c8c1f693f28 Date: 2016-04-30 00:37 +0100 http://bitbucket.org/pypy/pypy/changeset/7c8c1f693f28/
Log: fix fix fix diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -461,7 +461,7 @@ api_func = slot_tp_iter.api_func elif name == 'tp_iternext': - iternext_fn = w_type.getdictvalue(space, 'next') + iternext_fn = w_type.getdictvalue(space, '__next__') if iternext_fn is None: return diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -545,11 +545,6 @@ return type->tp_call(obj, c_args, NULL); ''')]) - class C: - def __call__(self, *args): - return args - assert module.tp_call(type(C()), C(), ('x', 2)) == ('x', 2) - class D(type): def __call__(self, *args): return "foo! %r" % (args,) @@ -601,10 +596,6 @@ ''' ) ]) - class C: - def __str__(self): - return "text" - assert module.tp_str(type(C()), C()) == "text" class D(int): def __str__(self): return "more text" @@ -683,9 +674,7 @@ PyErr_SetNone(PyExc_ValueError); return NULL; } - return type->tp_iter(obj); - ''' - ), + return type->tp_iter(obj);'''), ("tp_iternext", "METH_VARARGS", ''' PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); @@ -697,17 +686,16 @@ return NULL; } result = type->tp_iternext(obj); + /* In py3, returning NULL from tp_iternext means the iterator + * is exhausted */ if (!result && !PyErr_Occurred()) result = PyBytes_FromString("stop!"); - return result; - ''' - ) - ]) + return result;''')]) l = [1] it = module.tp_iter(list, l) assert type(it) is type(iter([])) assert module.tp_iternext(type(it), it) == 1 - raises(StopIteration, module.tp_iternext, type(it), it) + assert module.tp_iternext(type(it), it) == b'stop!' # class LL(list): def __iter__(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit