Guido van Rossum [Fri, 9 Aug 2002 16:16:30 +0000 (16:16 +0000)]
Doc portion of SF 589982 (tempfile.py rewrite, by Zack Weinberg).
Fred, please review!
Guido van Rossum [Fri, 9 Aug 2002 16:14:33 +0000 (16:14 +0000)]
Check-in of the most essential parts of SF 589982 (tempfile.py
rewrite, by Zack Weinberg). This replaces most code in tempfile.py
(please review!!!) and adds extensive unit tests for it.
This will cause some warnings in the test suite; I'll check those in
soon, and also the docs.
Guido van Rossum [Fri, 9 Aug 2002 16:11:37 +0000 (16:11 +0000)]
Test for Neil's fix to correctly invoke __rmul__.
Guido van Rossum [Fri, 9 Aug 2002 15:57:34 +0000 (15:57 +0000)]
News about Neil's fix to correctly invoke __rmul__.
Guido van Rossum [Fri, 9 Aug 2002 15:36:48 +0000 (15:36 +0000)]
Unicode replace() method with empty pattern argument should fail, like
it does for 8-bit strings.
Neil Schemenauer [Fri, 9 Aug 2002 15:20:48 +0000 (15:20 +0000)]
Only call sq_repeat if the object does not have a nb_multiply slot. One
example of where this changes behavior is when a new-style instance
defines '__mul__' and '__rmul__' and is multiplied by an int. Before the
change the '__rmul__' method is never called, even if the int is the
left operand.
Fred Drake [Fri, 9 Aug 2002 14:57:55 +0000 (14:57 +0000)]
New entries to track the DOM API growth. These match names exposed in
PyXML 0.8.
Jack Jansen [Fri, 9 Aug 2002 14:42:57 +0000 (14:42 +0000)]
When installing the "python" link in bindir also test for a pre-existing
symlink and remove it.
Jack Jansen [Fri, 9 Aug 2002 14:15:46 +0000 (14:15 +0000)]
- Precompile py files in Mac subtree after installing
- Pre-cache .rsrc files in Mac subtree after installing
- Fixed nameclash in Make variables
Jack Jansen [Fri, 9 Aug 2002 13:44:03 +0000 (13:44 +0000)]
- Check not only that cache file exists, but also that it is newer than
the applesingle file.
- Added optional verbose option for cachersrc tool.
Jack Jansen [Fri, 9 Aug 2002 13:42:55 +0000 (13:42 +0000)]
Tool to pre-created cached .rsrc.df.rsrc files in the Lib directories,
similar to compileall.py.
Sjoerd Mullender [Fri, 9 Aug 2002 13:37:31 +0000 (13:37 +0000)]
Document that -u puts stdin, stdout, and stderr in binary mode.
Sjoerd Mullender [Fri, 9 Aug 2002 13:35:18 +0000 (13:35 +0000)]
On Cygwin, put stdin, stderr, and stdout in binary mode when the -u
flag is given (to mimic native Windows).
Jack Jansen [Fri, 9 Aug 2002 10:22:11 +0000 (10:22 +0000)]
Obsolete now that there's a python implementation of strptime in the
standard lib.
Jack Jansen [Fri, 9 Aug 2002 10:17:28 +0000 (10:17 +0000)]
Patch by Russel Owen: if we have command line arguments zap pyc files
in the directories given.
Steve Purcell [Fri, 9 Aug 2002 09:46:23 +0000 (09:46 +0000)]
Fix to ensure consistent 'repr' and 'str' results between Python
versions, since 'repr(new_style_class) != repr(classic_class)'.
Suggested by Jeremy Hylton.
Jack Jansen [Fri, 9 Aug 2002 09:03:31 +0000 (09:03 +0000)]
Depracated some non-carbon modules.
Jack Jansen [Fri, 9 Aug 2002 09:02:01 +0000 (09:02 +0000)]
This file should have gone long ago.
Tim Peters [Fri, 9 Aug 2002 05:06:44 +0000 (05:06 +0000)]
Repaired a braino in the description of bad minrun values.
Neal Norwitz [Fri, 9 Aug 2002 03:37:42 +0000 (03:37 +0000)]
SF bug #592645 fix memory leak in socket.getaddrinfo
Fred Drake [Fri, 9 Aug 2002 02:39:13 +0000 (02:39 +0000)]
Update the text on the Expat module and library.
Guido van Rossum [Fri, 9 Aug 2002 02:14:34 +0000 (02:14 +0000)]
Major speedup for new-style class creation. Turns out there was some
trampolining going on with the tp_new descriptor, where the inherited
PyType_GenericNew was overwritten with the much slower slot_tp_new
which would end up calling tp_new_wrapper which would eventually call
PyType_GenericNew. Add a special case for this to update_one_slot().
XXX Hope there isn't a loophole in this. I'll buy the first person to
point out a bug in the reasoning a beer.
Backport candidate (but I won't do it).
Raymond Hettinger [Fri, 9 Aug 2002 01:37:06 +0000 (01:37 +0000)]
Moved inplace add and multiply methods from UserString to MutableString.
Closes SF Bug #592573 where inplace add mutated a UserString.
Added unittests to verify the bug is cleared.
Raymond Hettinger [Fri, 9 Aug 2002 01:30:17 +0000 (01:30 +0000)]
Moved special case for tuples from iterobject.c to
tupleobject.c. Makes the code in iterobject.c cleaner
and speeds-up the general case by not checking for
tuples everytime. SF Patch #592065.
Raymond Hettinger [Fri, 9 Aug 2002 00:43:38 +0000 (00:43 +0000)]
Revised the test suite for 'contains' to use the test() function argument
rather than vereq(). While it was effectively testing regular strings, it
ignored the test() function argument when called by test_userstring.py.
Jack Jansen [Fri, 9 Aug 2002 00:18:21 +0000 (00:18 +0000)]
By popular demand the frameworkinstall target now installs everything:
the framework, the MacOSX apps and the unix tools.
Most of the hard work is done by Mac/OSX/Makefile.
Also, it should now be possible to install in a different directory,
such as /tmp/dist/Library/Frameworks, for building binary installers.
The fink crowd wanted this.
Guido van Rossum [Thu, 8 Aug 2002 21:57:53 +0000 (21:57 +0000)]
Significant speedup in new-style object creation: in slot_tp_new(),
intern the string "__new__" so we can call PyObject_GetAttr() rather
than PyObject_GetAttrString(). (Though it's a mystery why slot_tp_new
is being called when a class doesn't define __new__. I'll look into
that tomorrow.)
2.2 backport candidate (but I won't do it).
Jack Jansen [Thu, 8 Aug 2002 21:16:56 +0000 (21:16 +0000)]
Use hex escape for non-ascii chars, now that the parser wants that.
Good thing, too: some of the characters had been mangled by OS9->CVS->OSX
roundtrips.
Guido van Rossum [Thu, 8 Aug 2002 20:55:20 +0000 (20:55 +0000)]
A modest speedup of object deallocation. call_finalizer() did rather
a lot of work: it had to save and restore the current exception around
a call to lookup_maybe(), because that could fail in rare cases, and
most objects don't have a __del__ method, so the whole exercise was
usually a waste of time. Changed this to cache the __del__ method in
the type object just like all other special methods, in a new slot
tp_del. So now subtype_dealloc() can test whether tp_del is NULL and
skip the whole exercise if it is. The new slot doesn't need a new
flag bit: subtype_dealloc() is only called if the type was dynamically
allocated by type_new(), so it's guaranteed to have all current slots.
Types defined in C cannot fill in tp_del with a function of their own,
so there's no corresponding "wrapper". (That functionality is already
available through tp_dealloc.)
Guido van Rossum [Thu, 8 Aug 2002 20:39:30 +0000 (20:39 +0000)]
The other half of the patches added to SF patch 555085 by A I
MacIntyre. At least on OS/2, a subsequent connect() on a nonblocking
socket returns errno==EISCONN to indicate success. This seems
harmless on Unix.
Guido van Rossum [Thu, 8 Aug 2002 20:37:08 +0000 (20:37 +0000)]
Clean up some docstrings. Some docstrings didn't show their return
value; others were inconsistent in what to name the argument or return
value; a few module-global functions had "socket." in front of their
name, against convention.
Guido van Rossum [Thu, 8 Aug 2002 20:28:34 +0000 (20:28 +0000)]
testSendAll(): loop until all data is read; this was necessary at
least on OS/2 (see note on SF patch 555085 by A I MacIntyre) but
looks like the test *could* fail on any other platform too -- there's
no guarantee that recv() reads all data.
Tim Peters [Thu, 8 Aug 2002 20:19:19 +0000 (20:19 +0000)]
Whitespace normalization.
Tim Peters [Thu, 8 Aug 2002 20:07:03 +0000 (20:07 +0000)]
Delete junk attributes left behind by _socketobject class construction.
Jason Tishler [Thu, 8 Aug 2002 19:46:15 +0000 (19:46 +0000)]
Patch #588561: Cygwin _hotshot patch
YA Cygwin module patch very similar to other patches
that I have submitted. I tested under Cygwin and Red
Hat Linux 7.1.
Guido van Rossum [Thu, 8 Aug 2002 18:11:36 +0000 (18:11 +0000)]
The _socketobject class has no need for a __del__ method: all it did was
to delete the reference to self._sock, and the regular destructor will
do that just fine. This made some hacks in close() unnecessary.
The _fileobject class still has a __del__ method, because it must flush.
Guido van Rossum [Thu, 8 Aug 2002 17:34:19 +0000 (17:34 +0000)]
OK, one more hack: speed up the case of readline() in unbuffered mode.
This is important IMO because httplib reads the headers this way.
Guido van Rossum [Thu, 8 Aug 2002 17:16:09 +0000 (17:16 +0000)]
Another refactoring of read() and readline(), this time based on the
observation that _rbuf could never have more than one string in it.
So make _rbuf a string. The code branches for size<0 and size>=0
are completely separate now, both in read() and in readline().
I checked for tabs this time. :-)
Guido van Rossum [Thu, 8 Aug 2002 15:25:28 +0000 (15:25 +0000)]
Extend __all__ with the exports list of the _ssl module.
Guido van Rossum [Thu, 8 Aug 2002 15:22:12 +0000 (15:22 +0000)]
Oops, stupid tabs. Sorry again.
Guido van Rossum [Thu, 8 Aug 2002 15:16:20 +0000 (15:16 +0000)]
Another refactoring. Changed 'socket' from being a factory function
to being a new-style class, to be more similar to the socket class
in the _socket module; it is now the same as the _socketobject class.
Added __slots__. Added docstrings, copied from the real socket class
where possible.
The _fileobject class is now also a new-style class with __slots__
(though without docstrings). The mode, name, softspace, bufsize and
closed attributes are properly supported (closed as a property; name
as a class attributes; the softspace, mode and bufsize as slots).
Steve Purcell [Thu, 8 Aug 2002 13:38:02 +0000 (13:38 +0000)]
Add module-wide "__metaclass__ = type", as requested by Jim Fulton.
(Synched from pyunit CVS)
Tim Peters [Thu, 8 Aug 2002 01:55:16 +0000 (01:55 +0000)]
Added info about highwater heap-memory use for the sortperf.py tests; + a
couple of minor edits elsewhere.
Tim Peters [Thu, 8 Aug 2002 01:06:39 +0000 (01:06 +0000)]
PyList_Reverse(): This was leaking a reference to Py_None on every call.
I believe I introduced this bug when I refactored the reversal code so
that the mergesort could use it too. It's not a problem on the 2.2 branch.
Guido van Rossum [Thu, 8 Aug 2002 01:02:16 +0000 (01:02 +0000)]
Major restructuring of _fileobject. Hopefully several things now work
correctly (the test at least succeed, but they don't test everything yet).
Also fix a performance problem in read(-1): in unbuffered mode, this would
read 1 byte at a time. Since we're reading until EOF, that doesn't make
sense. Use the default buffer size if _rbufsize is <= 1.
Guido van Rossum [Thu, 8 Aug 2002 01:00:28 +0000 (01:00 +0000)]
Replace docstrings on test functions witrh comments -- then unittest
prints function and module names, which is more informative now that
we repeat some tests in slightly modified subclasses.
Add a test for read() until EOF.
Add test suites for line-buffered (bufsize==1) and a small custom
buffer size (bufsize==2).
Restructure testUnbufferedRead() somewhat to avoid a potentially
infinite loop.
Tim Peters [Wed, 7 Aug 2002 20:53:05 +0000 (20:53 +0000)]
Added info about the right way to leave the body of a trashcan-protected
destructor early.
Guido van Rossum [Wed, 7 Aug 2002 20:42:09 +0000 (20:42 +0000)]
Fix a subtle bug in the trashcan code I added yesterday to
subtype_dealloc().
When call_finalizer() failed, it would return without going through
the trashcan end macro, thereby unbalancing the trashcan nesting level
counter, and thereby defeating the test case (slottrash() in
test_descr.py). This in turn meant that the assert in the GC_UNTRACK
macro wasn't triggered by the slottrash() test despite a bug in the
code: _PyTrash_destroy_chain() calls the dealloc routine with an
object that's untracked, and the assert in the GC_UNTRACK macro would
fail on this; but because of an earlier test that resurrects an
object, causing call_finalizer() to fail and the trashcan nesting
level to be unbalanced, so _PyTrash_destroy_chain() was never called.
Calling the slottrash() test in isolation *did* trigger the assert,
however.
So the fix is twofold: (1) call the GC_UnTrack() function instead of
the GC_UNTRACK macro, because the function is safe when the object is
already untracked; (2) when call_finalizer() fails, jump to a label
that exits through the trashcan end macro, keeping the trashcan
nesting balanced.
Raymond Hettinger [Wed, 7 Aug 2002 20:20:52 +0000 (20:20 +0000)]
GvR pointed out that only enclosing function bodies are part of nested scopes.
Guido van Rossum [Wed, 7 Aug 2002 19:06:27 +0000 (19:06 +0000)]
Add -E and -tt options to the python invocations, as for the Unix tests.
The -tt means modules that mix tabs and spaces will be rejected.
The -E refuses to believe Python options in the environment.
Guido van Rossum [Wed, 7 Aug 2002 19:03:35 +0000 (19:03 +0000)]
Replace tabs with spaces. (Sorry!)
Guido van Rossum [Wed, 7 Aug 2002 19:02:49 +0000 (19:02 +0000)]
Tighten the unbuffered readline test to distinguish between the two lines.
Guido van Rossum [Wed, 7 Aug 2002 18:58:11 +0000 (18:58 +0000)]
Simplify heapreplace() -- there's no need for an explicit test for
empty heap, since heap[0] raises the appropriate IndexError already.
Guido van Rossum [Wed, 7 Aug 2002 18:56:08 +0000 (18:56 +0000)]
Document that heappop() and heapreplace() raise IndexError if the heap
is empty.
Raymond Hettinger [Wed, 7 Aug 2002 16:53:17 +0000 (16:53 +0000)]
Apply character{} markup.
Martin v. Löwis [Wed, 7 Aug 2002 16:21:51 +0000 (16:21 +0000)]
Replace abort with Py_FatalError.
Raymond Hettinger [Wed, 7 Aug 2002 16:18:54 +0000 (16:18 +0000)]
Described responsibilty of weakly referenced extension types to initialize
the weakreflist to NULL in the constructor and to fill the tp_flags
slot with Py_TPFLAGS_HAVE_WEAKREFS. Closes SF bug 586583.
Raymond Hettinger [Wed, 7 Aug 2002 16:09:48 +0000 (16:09 +0000)]
Describe nested scopes in the tutorial. Closes SF bug 500704.
Guido van Rossum [Wed, 7 Aug 2002 16:03:06 +0000 (16:03 +0000)]
Oops. I accidentally commented out some tests.
Jack Jansen [Wed, 7 Aug 2002 15:53:42 +0000 (15:53 +0000)]
Regenerated with OSA class inheritance and fix for non-ascii chars.
Jack Jansen [Wed, 7 Aug 2002 15:52:44 +0000 (15:52 +0000)]
Fixed incorrect logic in determining whether we should initialize
the classes' attribute list.
Raymond Hettinger [Wed, 7 Aug 2002 15:48:17 +0000 (15:48 +0000)]
Documented os.fsync and os.fdatasync. Closes SF bug 584695.
Guido van Rossum [Wed, 7 Aug 2002 15:46:19 +0000 (15:46 +0000)]
"Unbuffered" mode of class _fileobject wasn't actually unbuffered,
and this broke a Zope "pipelining" test which read multiple responses
from the same connection (this attaches a new file object to the
socket for each response). Added a test for this too.
(I want to do some code cleanup too, but I thought I'd first fix
the problem with as little code as possible, and add a unit test
for this case. So that's what this checkin is about.)
Jack Jansen [Wed, 7 Aug 2002 15:44:53 +0000 (15:44 +0000)]
- If an OSA identifier is a Python reserved word we now append an _
in stead of prepending it, which messes up "import * from".
- A few ascii()s added again.
- Changed the getbaseclasses a little, but it still isn't perfect.
Fred Drake [Wed, 7 Aug 2002 15:40:15 +0000 (15:40 +0000)]
Clarify that the bool instances are acceptable return values from
__nonzero__(), in response to SF bug #579991.
Martin v. Löwis [Wed, 7 Aug 2002 15:18:57 +0000 (15:18 +0000)]
Use Py_FatalError instead of abort.
Jack Jansen [Wed, 7 Aug 2002 15:05:42 +0000 (15:05 +0000)]
Don't be over-enthusiastic with the ascii() calls: we don't need it if
the result passes through backticks.
Jack Jansen [Wed, 7 Aug 2002 14:49:00 +0000 (14:49 +0000)]
Donovan Preston's patch #538395, with some mods by me.
This patch makes inheritance for OSA classes work. The implementation is a
bit convoluted, but I don't immedeately see a simpler way of doing it.
I added calls to ascii() everywhere we output strings that may contain
non-ascii characters (Python has gotten very picky since the encoding
patch:-).
I also removed Donovan's different way of opening resource files: I don't
seem to need it.
Jack Jansen [Wed, 7 Aug 2002 14:05:58 +0000 (14:05 +0000)]
Quote the arguments, they may contain strings.
Fred Drake [Wed, 7 Aug 2002 13:24:09 +0000 (13:24 +0000)]
Fix up some more markup problems.
Fred Drake [Wed, 7 Aug 2002 12:39:33 +0000 (12:39 +0000)]
Change the markup a bit more; the parameter was not marked as \var in the
sample code, and the note was marked as a logical thing.
Martin v. Löwis [Wed, 7 Aug 2002 12:33:18 +0000 (12:33 +0000)]
Fix PEP 263 code --without-unicode. Fixes #591943.
Steve Holden [Wed, 7 Aug 2002 12:01:41 +0000 (12:01 +0000)]
Fix markup errors.
Raymond Hettinger [Tue, 6 Aug 2002 23:08:51 +0000 (23:08 +0000)]
Expanded the unittests for the new width sensitive PyUnicode_Contains().
Raymond Hettinger [Tue, 6 Aug 2002 22:36:26 +0000 (22:36 +0000)]
Document handling of raw-unicode-escapes. Closes SF bug 587087.
Tim Peters [Tue, 6 Aug 2002 22:25:02 +0000 (22:25 +0000)]
internal_connect(): Windows. When sock_timeout > 0 and connect() yields
WSAEWOULDBLOCK, the second connect() attempt appears to yield WSAEISCONN
on Win98 but WSAEINVAL on Win2K. So accept either as meaning "yawn,
fine". This allows test_socket to succeed on my Win2K box (which it
already did on my Win98SE box).
Jack Jansen [Tue, 6 Aug 2002 22:15:23 +0000 (22:15 +0000)]
Added a note about the inability to specify a pathname to a non-existing
file in unix-Python.
Jack Jansen [Tue, 6 Aug 2002 22:14:23 +0000 (22:14 +0000)]
Changed a sentence that confused some people.
Neal Norwitz [Tue, 6 Aug 2002 22:12:52 +0000 (22:12 +0000)]
Make more functions static
Neal Norwitz [Tue, 6 Aug 2002 21:50:54 +0000 (21:50 +0000)]
Make readahead functions static
Guido van Rossum [Tue, 6 Aug 2002 21:41:44 +0000 (21:41 +0000)]
Fix SF bug 574207 (chained __slots__ dealloc segfault).
This is inspired by SF patch 581742 (by Jonathan Hogg, who also
submitted the bug report, and two other suggested patches), but
separates the non-GC case from the GC case to avoid testing for GC
several times.
Had to fix an assert() from call_finalizer() that asserted that the
object wasn't untracked, because it's possible that the object isn't
GC'ed!
Fred Drake [Tue, 6 Aug 2002 21:36:06 +0000 (21:36 +0000)]
Fix the markup so it doesn't break formatting.
Guido van Rossum [Tue, 6 Aug 2002 21:28:28 +0000 (21:28 +0000)]
Add testcase for SF bug 574207 (chained __slots__ dealloc segfault).
Fix forthcoming.
Fred Drake [Tue, 6 Aug 2002 21:26:01 +0000 (21:26 +0000)]
Added references to the email package.
Closes SF bug #586937.
Barry Warsaw [Tue, 6 Aug 2002 19:03:56 +0000 (19:03 +0000)]
Added a test for PyUnicode_Contains() taking into account the width of
Py_UNICODE.
Barry Warsaw [Tue, 6 Aug 2002 19:03:17 +0000 (19:03 +0000)]
PyUnicode_Contains(): The memcmp() call didn't take into account the
width of Py_UNICODE. Good catch, MAL.
Skip Montanaro [Tue, 6 Aug 2002 17:47:40 +0000 (17:47 +0000)]
get rid of GETNAMEV macro - use GETITEM directly
same idea as getting rid of GETCONST & GETNAME (see patch #506436)
Guido van Rossum [Tue, 6 Aug 2002 17:29:38 +0000 (17:29 +0000)]
Add a coding cookie, because of the møøse quote.
Guido van Rossum [Tue, 6 Aug 2002 17:28:30 +0000 (17:28 +0000)]
Update the URL for getting zlib, and update the minimal required
version to 1.1.4 (because of the 1.1.3 security problem). Also
replace a funny use of line.find() with line.startswith().
Guido van Rossum [Tue, 6 Aug 2002 17:21:20 +0000 (17:21 +0000)]
Bump the LOOPS count. 50,000 iterations takes about 5 seconds on my
machine -- that feels just right.
Guido van Rossum [Tue, 6 Aug 2002 17:18:56 +0000 (17:18 +0000)]
Add some fine points: METH_KEYWORDS implies METH_VARARGS, and ob_size
is no longer unused in type objects.
Guido van Rossum [Tue, 6 Aug 2002 17:14:04 +0000 (17:14 +0000)]
Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py.
Guido van Rossum [Tue, 6 Aug 2002 17:03:25 +0000 (17:03 +0000)]
Remove mention of deprecated xreadlines method.
Barry Warsaw [Tue, 6 Aug 2002 17:01:51 +0000 (17:01 +0000)]
Describe new "str1 in str2" behavior.
Guido van Rossum [Tue, 6 Aug 2002 17:01:28 +0000 (17:01 +0000)]
Document file.next(). Mark xreadlines obsolete (both method and
module). (One thing remains to be done: the gzip class has an
xreadline method; this ought to be replaced by an iterator as well.)
Barry Warsaw [Tue, 6 Aug 2002 16:58:21 +0000 (16:58 +0000)]
Committing patch #591250 which provides "str1 in str2" when str1 is a
string of longer than 1 character.
Guido van Rossum [Tue, 6 Aug 2002 16:20:26 +0000 (16:20 +0000)]
Files are now their own iterator. The xreadlines method and module
are obsolete.
Steve Holden [Tue, 6 Aug 2002 16:07:07 +0000 (16:07 +0000)]
Add comment about os.path.walk()'s behavior with symbolic links.
Guido van Rossum [Tue, 6 Aug 2002 15:58:24 +0000 (15:58 +0000)]
Add next and __iter__ to the list of file methods that should raise
ValueError when called for a closed file.
Guido van Rossum [Tue, 6 Aug 2002 15:55:28 +0000 (15:55 +0000)]
SF patch 580331 by Oren Tirosh: make file objects their own iterator.
For a file f, iter(f) now returns f (unless f is closed), and f.next()
is similar to f.readline() when EOF is not reached; however, f.next()
uses a readahead buffer that messes up the file position, so mixing
f.next() and f.readline() (or other methods) doesn't work right.
Calling f.seek() drops the readahead buffer, but other operations
don't.
The real purpose of this change is to reduce the confusion between
objects and their iterators. By making a file its own iterator, it's
made clearer that using the iterator modifies the file object's state
(in particular the current position).
A nice side effect is that this speeds up "for line in f:" by not
having to use the xreadlines module. The f.xreadlines() method is
still supported for backwards compatibility, though it is the same as
iter(f) now.
(I made some cosmetic changes to Oren's code, and added a test for
"file closed" to file_iternext() and file_iter().)