NEEDS DOC CHANGES.
Possibly contentious: The first time s.next() yields StopIteration (for
a given map argument s) is the last time map() *tries* s.next(). That
is, if other sequence args are longer, s will never again contribute
anything but None values to the result, even if trying s.next() again
could yield another result. This is the same behavior map() used to have
wrt IndexError, so it's the only way to be wholly backward-compatible.
I'm not a fan of letting StopIteration mean "try again later" anyway.
to no longer insist that len(seq) be defined.
NEEDS DOC CHANGES.
This is meant to be a model for how other functions of this ilk (max,
filter, etc) can be generalized similarly. Feel encouraged to grab your
favorite and convert it!
Note some cute consequences:
list(file) == file.readlines() == list(file.xreadlines())
list(dict) == dict.keys()
list(dict.iteritems()) = dict.items()
list(xrange(i, j, k)) == range(i, j, k)
The new test case demonstrates the bug. Be more careful in
symtable_resolve_free() to add a var to cells or frees only if it
won't be added under some other rule.
XXX Add new assertion that will catch this bug.
of ParserCreate().
Added assignment tests for the ordered_attributes and specified_attributes
values, similar to the checks for the returns_unicode attribute.
Obviously bad regexps, spotted by Jeffery Collins.
HELP! I can't run this on Windows, and the module test() function
probably doesn't work on anyone's box. Could a Unixoid please write
an at least minimal working test and add it to the std test suite?
new slot tp_iter in type object, plus new flag Py_TPFLAGS_HAVE_ITER
new C API PyObject_GetIter(), calls tp_iter
new builtin iter(), with two forms: iter(obj), and iter(function, sentinel)
new internal object types iterobject and calliterobject
new exception StopIteration
new opcodes for "for" loops, GET_ITER and FOR_ITER (also supported by dis.py)
new magic number for .pyc files
new special method for instances: __iter__() returns an iterator
iteration over dictionaries: "for x in dict" iterates over the keys
iteration over files: "for x in file" iterates over lines
TODO:
documentation
test suite
decide whether to use a different way to spell iter(function, sentinal)
decide whether "for key in dict" is a good idea
use iterators in map/filter/reduce, min/max, and elsewhere (in/not in?)
speed tuning (make next() a slot tp_next???)
I know some people don't like this -- if it's really controversial,
I'll take it out again. (If it's only Alex Martelli who doesn't like
it, that doesn't count as "real controversial" though. :-)
That's why this is a separate checkin from the iterators stuff I'm
about to check in next.
Weak*Dictionary.update(): No longer create a temporary list to hold the
things that will be stuffed into the underlying dictionary. This had
been done so that if any of the objects used as the weakly-held value
was not weakly-referencable, no updates would take place (TypeError
would be raised). With this change, TypeError will still be raised
but a partial update could occur. This is more like other .update()
implementations.
Thoughout, use of the name "ref" as a local variable has been removed. The
original use of the name occurred when the function to create a weak
reference was called "new"; the overloaded use of the name could be
confusing for someone reading the code. "ref" used as a variable name
has been replaced with "wr" (for 'weak reference').
The changes cause compilation failures in any file in the Python
installation lib directory to cause the install to fail. It looks
like compileall.py intended to behave this way, but a change to
py_compile.py and a separate bug defeated it.
Fixes SF bug #412436
This change affects the test suite, which contains several files that
contain intentional errors. The solution is to extend compileall.py
with the ability to skip compilation of selected files.
NB compileall.py is changed so that compile_dir() returns success only
if all recursive calls to compile_dir() also check success.
The changes cause compilation failures in any file in the Python
installation lib directory to cause the install to fail. It looks
like compileall.py intended to behave this way, but a change to
py_compile.py and a separate bug defeated it.
Fixes SF bug #412436
This change affects the test suite, which contains several files that
contain intentional errors. The solution is to extend compileall.py
with the ability to skip compilation of selected files.
In the test suite, rename nocaret.py and test_future[3..7].py to start
with badsyntax_nocaret.py and badsyntax_future[3..7].py. Update the
makefile to skip compilation of these files. Update the tests to use
the name names for imports.
NB compileall.py is changed so that compile_dir() returns success only
if all recursive calls to compile_dir() also check success.
file was deleted by a previous call to the visitor function.
This used to be the behavior in 1.5.2 and before, but a patch to avoid
making two stat() calls accidentally broke this in 2.0.
Moshe, this would be a good one for 2.0.1 too!
its first return statement returns a single value while its caller
always expects it to return a tuple of two items. Fix this by
returning (s, 0) instead.
This won't make the locale test on Irix succeed, but now it will fail
because of a bug in the platform's en_US locale rather than because of
a bug in the locale module.
than from module pickletester. Using the latter turned out to cause
the test to break when invoked as "import test.test_pickle" or "import
test.autotest".
cut-and-paste copy of the seek() method on the _Subfile class, but it
didn't make one bit of sense: it sets self.pos, which is not used in
this class or its subclasses, and it uses self.start and self.stop,
which aren't defined on this class or its subclasses. This is purely
my own fault -- I added this in rev 1.4 and apparently never tried to
use it. Since it's not documented, and of very questionable use given
that there's no tell(), I'm ripping it out.
This resolves SF bug 416199 by Andrew Dalke: mailbox.py seek problems.
ZipFile.close() method that should be part of the preceding 'if'
block. On some platforms (Mark noticed this on FreeBSD 4.2) doing a
flush() on a file open for reading is not allowed.