summaryrefslogtreecommitdiffstats
path: root/Lib/io.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename buffer -> bytearray.Guido van Rossum2007-11-211-6/+6
|
* Oops, I missed this one again (test_univnewlines fails):Amaury Forgeot d'Arc2007-11-191-1/+1
| | | | | | Some incremental decoders return multiple characters, even when fed with only one more byte. In this case the tell() state must subtract the number of extra characters.
* Issue1395: Universal mode used to duplicate newlines when using read(1).Amaury Forgeot d'Arc2007-11-191-89/+116
| | | | | | | | | | "Universal newline" is now an incremental decoder wrapping the initial one, with its own additional buffer (if '\r' is seen at the end of the input). A decoder allows the tell() funtion to record the state of the translation. This also simplifies the readline() process. Now test_netrc passes on Windows, as well as many new tests in test_io.py
* seek() has to accept any int-like numberChristian Heimes2007-11-091-2/+4
|
* Fixed bug #1081: file.seek allows float argumentsChristian Heimes2007-11-081-0/+2
|
* Fixed #1403 where compileall and py_compile choked on an encoding header in ↵Christian Heimes2007-11-081-0/+3
| | | | a py file. Both modules need more unit tests.
* Merging the py3k-pep3137 branch back into the py3k branch.Guido van Rossum2007-11-061-14/+16
| | | | | | | | | | | | | | No detailed change log; just check out the change log for the py3k-pep3137 branch. The most obvious changes: - str8 renamed to bytes (PyString at the C level); - bytes renamed to buffer (PyBytes at the C level); - PyString and PyUnicode are no longer compatible. I.e. we now have an immutable bytes type and a mutable bytes type. The behavior of PyString was modified quite a bit, to make it more bytes-like. Some changes are still on the to-do list.
* Fix typo.Georg Brandl2007-10-301-1/+1
|
* Patch 1329 (partial) by Christian Heimes.Guido van Rossum2007-10-301-4/+9
| | | | | | | | Add a closefd flag to open() which can be set to False to prevent closing the file descriptor when close() is called or when the object is destroyed. Useful to ensure that sys.std{in,out,err} keep their file descriptors open when Python is uninitialized. (This was always a feature in 2.x, it just wasn't implemented in 3.0 yet.)
* Patch 1330 by Christian Heimes (with some TLC applied by myself).Guido van Rossum2007-10-261-14/+4
| | | | | Move most of the messiness with truncate() on Windows into _fileio.c. Still keep the flush() call in io.py though.
* Patch # 1323 by Amaury Forgeot d'Arc.Guido van Rossum2007-10-251-2/+17
| | | | | | This patch corrects a problem in test_file.py on Windows: f.truncate() seeks to the truncation point, but does not empty the buffers. In the test, f.tell() returns -1...
* Patch 1267 by Christian Heimes.Guido van Rossum2007-10-191-0/+12
| | | | | | Move the initialization of sys.std{in,out,err} and __builtin__.open to C code. This solves the problem that "python -S" wouldn't work.
* Patch# 1258 by Christian Heimes: kill basestring.Guido van Rossum2007-10-161-5/+5
| | | | I like this because it makes the code shorter! :-)
* Make the docstring for io.open() a raw string so that the explanation for theBrett Cannon2007-10-151-1/+1
| | | | 'newline' argument is not a jumbled mess of newlines.
* Remove self-referential import.Brett Cannon2007-10-111-2/+1
|
* In rseponse to bug# 1029, force the newline default for StringIO to "\n",Guido van Rossum2007-08-291-1/+1
| | | | so that even on Windows, after s.write("x\n"), s.getvalue() == "x\n".
* Insist that the argument to TextIOWrapper.write() is a basestringGuido van Rossum2007-08-291-0/+3
| | | | | instance. This was effectively already the case, but the error reporting was lousy.
* Commit strict str/bytes distinction.Guido van Rossum2007-08-291-8/+5
| | | | | | | | | From now on, trying to write str to a binary stream is an error (I'm still working on the reverse). There are still (at least) two failing tests: - test_asynchat - test_urllib2_localnet but I'm sure these will be fixed by someone.
* Changes to io.py and socket.py by Christian Heimes.Guido van Rossum2007-08-271-25/+57
| | | | | | | | | - Replace all asserts by ValuleErrors or TypeErrors as appropriate. - Add _checkReadable, _checkWritable methods; these check self.closed too. - Add a test that everything exported by io.py exists, and is either an exception or an IOBase instance (except for the open function). - Default buffering to 1 if isatty() (I had to tweak this to enforce the *default* bit -- GvR).
* Make IOBase (and hence all other classes in io.py) use ABCMeta as its metaclass,Guido van Rossum2007-08-221-1/+2
| | | | so you can use their class .register() method to register virtual subclasses.
* New I/O code from Tony Lownds implement newline feature correctly,Guido van Rossum2007-08-181-50/+160
| | | | and implements .newlines attribute in a 2.x-compatible fashion.
* Fix test_wsgiref that used StringIO and a BufferedReader rather thanNeal Norwitz2007-08-111-1/+2
| | | | | real files. This code assumed that fileno() would succeed which wasn't the case.
* Fall back to ascii if the locale module cannot be loaded.Martin v. Löwis2007-08-111-2/+7
|
* Set sys.stdout.encoding properly.Martin v. Löwis2007-08-111-2/+7
| | | | | Always set LC_CTYPE on interpreter startup. Add device_encoding function.
* SF patch# 1770008 by Christian Heimes (plus some extras).Guido van Rossum2007-08-091-0/+5
| | | | | | | | | | Completely get rid of StringIO.py and cStringIO.c. I had to fix a few tests and modules beyond what Christian did, and invent a few conventions. E.g. in elementtree, I chose to write/return Unicode strings whe no encoding is given, but bytes when an explicit encoding is given. Also mimetools was made to always assume binary files.
* 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
|