[pypy-commit] pypy SpecialisedTuples: Fix: make sure that PySequence_Fast() returns a W_ListObject
arigo
noreply at buildbot.pypy.org
Sun Dec 11 11:37:30 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: SpecialisedTuples
Changeset: r50370:5e1080705d7c
Date: 2011-12-11 11:29 +0100
http://bitbucket.org/pypy/pypy/changeset/5e1080705d7c/
Log: Fix: make sure that PySequence_Fast() returns a W_ListObject or a
W_TupleObject, not just some object of type list or tuple. The
reason is that PySequence_Fast_GET_xxx() expects these exact interp-
level types.
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -42,11 +42,11 @@
which case o is returned. Use PySequence_Fast_GET_ITEM() to access the
members of the result. Returns NULL on failure. If the object is not a
sequence, raises TypeError with m as the message text."""
- if (space.is_true(space.isinstance(w_obj, space.w_list)) or
- space.is_true(space.isinstance(w_obj, space.w_tuple))):
+ if (isinstance(w_obj, listobject.W_ListObject) or
+ isinstance(w_obj, listobject.W_TupleObject)):
return w_obj
try:
- return space.newtuple(space.fixedview(w_obj))
+ return listobject.W_TupleObject(space.fixedview(w_obj))
except OperationError:
raise OperationError(space.w_TypeError, space.wrap(rffi.charp2str(m)))
More information about the pypy-commit
mailing list