summaryrefslogtreecommitdiffstats
path: root/Lib/io.py
Commit message (Collapse)AuthorAgeFilesLines
* Make sure socket.close() doesn't interfere with socket.makefile().Jeremy Hylton2007-08-031-28/+0
| | | | | | | | | | | | | | | | | | | | If a makefile()-generated object is open and its parent socket is closed, the parent socket should remain open until the child is closed, too. The code to support this is moderately complex and requires one extra slots in the socket object. This change fixes httplib so that several urllib2net test cases pass again. Add SocketCloser class to socket.py, which encapsulates the refcounting logic for sockets after makefile() has been called. Move SocketIO class from io module to socket module. It's only use is to implement the raw I/O methods on top of a socket to support makefile(). Add unittests to test_socket to cover various patterns of close and makefile.
* Fix the minidom test.Guido van Rossum2007-07-271-3/+5
| | | | | In order to do this, I added an optional encoding argument to io.StringIO. The toprettyxml() function returns bytes when you specify an encoding now.
* Delete redundant read() and close() methods from SocketIO class.Guido van Rossum2007-07-271-24/+0
|
* Make close() (all versions) ignore IOError from flush().Guido van Rossum2007-07-221-4/+11
| | | | | | | This makes test_resource.py pass, and I think it's the right thing to do: if you're closing a file after encountering an I/O error there's nothing you can do about it. If you want the error, you can call flush() yourself.
* SF patch# 1757683 by Alexandre Vassalotti. Add support forGuido van Rossum2007-07-211-0/+5
| | | | seeking/writing beyond EOF to io.BytesIO.
* Set closed flag *after* calling flush().Guido van Rossum2007-07-101-2/+4
|
* Add proper tests for closed files to various I/O operations,Guido van Rossum2007-07-101-4/+21
| | | | | restoring a disabled test. This was necessary to make test_pickle.py pass.
* Made test_file pass. This meant adding support for read(-1) and read()Guido van Rossum2007-07-101-35/+56
| | | | | | | | to even the most basic file object (I also added readall() which may be a better API). Also, not all the tests requiring specific failure modes could be saved. And there were the usual str/bytes issues. I made sure test_io.py still passes (io.py is now most thoroughly tested by combining test_file.py and test_io.py).
* Make test_socket work.Guido van Rossum2007-06-081-7/+13
| | | | Don't exclude test_socket from the tests to run.
* Accellerate binary readline() a bit.Guido van Rossum2007-06-071-8/+14
|
* tokenizer.c: make coding markup work again.Guido van Rossum2007-06-071-2/+1
| | | | | | | | | | io.open() now takes all positional parameters (so we can conveniently call it from C code). test_tarfile.py no longer uses u"..." literals, but is otherwise still badly broken. This is a checkpoint; some more stuff now breaks.
* Remove debug print.Walter Dörwald2007-05-291-1/+0
|
* Fix typo.Walter Dörwald2007-05-291-1/+2
|
* Add isatty() to TextIOWrapper.Guido van Rossum2007-05-271-0/+3
|
* Add an encoding property to TextIOBase instances.Guido van Rossum2007-05-241-0/+9
| | | | | Add sys.__std{in,out,err}__. Make test_sys pass.
* Make test_subprocess work. Fix universal newlines in io.py.Guido van Rossum2007-05-241-14/+6
|
* Remove native popen() and fdopen(), replacing them with subprocess calls.Guido van Rossum2007-05-241-2/+6
| | | | | Fix a path to an assert in fileio_read(). Some misc tweaks.
* Sockets facelift. APIs that could return binary data (e.g. aton() andGuido van Rossum2007-05-211-17/+37
| | | | | | | | | recv()) now return bytes, not str or str8. The socket.py code is redone; it now subclasses _socket.socket and instead of having its own _fileobject for makefile(), it uses io.SocketIO. Some stuff in io.py was moved around to make this work. (I really need to rethink my policy regarding readline() and read(-1) on raw files; and readline() on buffered files ought to use peeking(). Later.)
* Make all the multibyte codec tests pass.Guido van Rossum2007-05-171-72/+57
| | | | | | | | Changes to io.py, necessary to make this work: - Redid io.StringIO as a TextIOWrapper on top of a BytesIO instance. - Got rid of _MemoryIOMixin, folding it into BytesIO instead. - The read() functions that take -1 to mean "eveything" now also take None. - Added readline() support to BufferedIOBase. :-(
* Fix io.StringIO for wide Python builds.Walter Dörwald2007-05-161-6/+11
|
* Fix io.StringIO: String are stored encoded (using "unicode-internal" as theWalter Dörwald2007-05-161-15/+30
| | | | | | | | | encoding) which makes the buffer mutable. Strings are encoded on the way in and decoded on the way out. Use io.StringIO in test_codecs.py. Fix the base64_codec test in test_codecs.py.
* Add to an XXX comment.Guido van Rossum2007-05-091-1/+2
|
* Fix a few places where a str instead of a bytes object was used.Guido van Rossum2007-05-081-1/+1
|
* PEP 3114: rename .next() to .__next__() and add next() builtin.Georg Brandl2007-04-211-2/+2
|
* Instead of pickling the whole decoder, use the new getstate/setstate API.Guido van Rossum2007-04-171-33/+27
|
* Support name and mode attributes on all file types.Guido van Rossum2007-04-131-10/+81
| | | | | | Don't read more than one line when reading text from a tty device. Add peek() and read1() methods. Return str instead of unicode when return ASCII characters in text mode.
* Make a few more tests pass with the new I/O library.Guido van Rossum2007-04-121-2/+0
| | | | | | Fix the truncate() semantics -- it should not affect the current position. Switch wave.py/chunk.py to struct.unpack_from() to support bytes. Don't use writelines() on binary files (test_fileinput.py).
* Make sure that writing an array instance returns the number of bytes,Guido van Rossum2007-04-121-1/+6
| | | | not the number of array elements.
* TextIO improvement:Guido van Rossum2007-04-121-3/+5
| | | | | - 25% speed increse in tell(); - f.seek(0, 1) now maps to f.seek(f.tell(), 0) instead of to f.tell().
* Speed up next() by disabling snapshot updating then.Guido van Rossum2007-04-111-5/+19
|
* More efficient implementation of tell(); _read_chunk() doesn't have toGuido van Rossum2007-04-111-29/+34
| | | | call self.buffer.tell().
* Real pickling for bytes.Guido van Rossum2007-04-111-1/+5
| | | | | Restore complex pickling. Use cPickle in io.py.
* Checkpoint so I can continue to work on this at a different box.Guido van Rossum2007-04-111-25/+145
| | | | | There is somewhat working (but slow) code supporting seek/tell for text files, but extensive testing exposes a bug I can't nail down.
* truncate() returns the new size and position.Guido van Rossum2007-04-101-11/+14
| | | | | | | | write() returns the number of bytes/characters written/buffered. FileIO.close() calls self.flush(). Implement readinto() for buffered readers. Tests th check all these. Test proper behavior of __enter__/__exit__.
* Implement long positioning (Unix only, probably).Guido van Rossum2007-04-101-14/+22
| | | | Etc., etc.
* BufferedIOBase and TextIOBase should derive from IOBase, not from RawIOBase!Guido van Rossum2007-04-101-3/+2
|
* More cleanup. Renamed BlockingIO to BlockingIOError.Guido van Rossum2007-04-101-253/+312
| | | | | | Removed unused _PyFileIO class. Changed inheritance structure. TODO: do the same kinds of things to TextIO.
* Cleanup.Guido van Rossum2007-04-081-61/+124
| | | | | | | | | Add closed attribute. Support int argument to open() -- wrapping a file descriptor. For b/w compat, support readline(n). Support readlines() and readlines(n). Flush on __del__. Added some XXX comments.
* Add some backwards compatibility stuff.Guido van Rossum2007-04-071-4/+29
| | | | | This now appears to work when io.open is substituted for the real open in fileinput.py -- at least the latter's unit tests pass.
* Checkpoint.Guido van Rossum2007-04-061-16/+49
| | | | | Some cleanup of test_io.py and io.py. Added seeking to buffered reader and writer, but no tests yet.
* Get rid of duplicate definition of BufferedIOBase.Guido van Rossum2007-04-061-12/+6
|
* Added a working Text I/O layer, by Mark Russell.Guido van Rossum2007-04-061-26/+257
| | | | This is essentially a checkpoint.
* Bug 1679498: remove unused instance variables _readable, _writable andGuido van Rossum2007-03-181-4/+0
| | | | _seekable.
* Bug 1679498: unset variable 'bs'.Guido van Rossum2007-03-181-0/+2
|
* Add some XXX comments and fix BufferedReader signature.Guido van Rossum2007-03-151-2/+6
|
* Check in Daniel Stutzbach's _fileio.c and test_fileio.pyGuido van Rossum2007-03-081-1/+13
| | | | | | (see SF#1671314) with small tweaks. The io module now uses this instead of its own implementation of the FileIO class, if it can import _fileio.
* Change the specs for readinto() -- it should *not* shorten the buffer toGuido van Rossum2007-03-071-4/+10
| | | | the amount of data read.
* New version from Mike Verdone (sat in my inbox since 2/27).Guido van Rossum2007-03-071-57/+174
| | | | | | | I cleaned up whitespace but otherwise didn't change it. This will need work to reflect the tentative decision to drop nonblocking I/O support from the buffering layers.
* Mike Verdone's checkpoint, cleaned up.Guido van Rossum2007-02-271-12/+132
| | | | | | Also implemented Neal's suggestion (add fileno() to SocketIO) and some unrelated changes, e.g. remove Google copyright and make BytesIO a subclass of BufferedIOBase.
* Added some comments and docstrings. More is needed.Guido van Rossum2007-02-271-16/+62
|