• Tim Peters's avatar
    Generalize tuple() to work nicely with iterators. · 6912d4dd
    Tim Peters yazdı
    NEEDS DOC CHANGES.
    This one surprised me!  While I expected tuple() to be a no-brainer, turns
    out it's actually dripping with consequences:
    1. It will *allow* the popular PySequence_Fast() to work with any iterable
       object (code for that not yet checked in, but should be trivial).
    2. It caused two std tests to fail.  This because some places used
       PyTuple_Sequence() (the C spelling of tuple()) as an indirect way to test
       whether something *is* a sequence.  But tuple() code only looked for the
       existence of sq->item to determine that, and e.g. an instance passed
       that test whether or not it supported the other operations tuple()
       needed (e.g., __len__).  So some things the tests *expected* to fail
       with an AttributeError now fail with a TypeError instead.  This looks
       like an improvement to me; e.g., test_coercion used to produce 559
       TypeErrors and 2 AttributeErrors, and now they're all TypeErrors.  The
       error details are more informative too, because the places calling this
       were *looking* for TypeErrors in order to replace the generic tuple()
       "not a sequence" msg with their own more specific text, and
       AttributeErrors snuck by that.
    6912d4dd
Adı
Son kayıt (commit)
Son güncelleme
Demo Loading commit data...
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
PCbuild Loading commit data...
Parser Loading commit data...
Python Loading commit data...
RISCOS Loading commit data...
Tools Loading commit data...
.cvsignore Loading commit data...
.hgtags Loading commit data...
LICENSE Loading commit data...
Makefile.pre.in Loading commit data...
README Loading commit data...
acconfig.h Loading commit data...
config.h.in Loading commit data...
configure Loading commit data...
configure.in Loading commit data...
install-sh Loading commit data...
setup.py Loading commit data...