Commit Graph

397 Commits

Author SHA1 Message Date
Ka-Ping Yee d24a5b603a Added a longish test case to stress seek/tell with a stateful decoder. 2008-03-20 10:51:27 +00:00
Neal Norwitz e2b070558c Revert r61508: it caused test_mailbox to fail on all platforms. 2008-03-18 19:52:05 +00:00
Ka-Ping Yee 30cc83832d In TextIOWrapper:
- Switch from consuming _decoded_text to advancing an offset into it.
  - Fix readline() interaction with seek/tell.
  - Fix readline() handling of 'limit' argument.

Add tests for seek/tell after readline().
2008-03-18 07:01:49 +00:00
Ka-Ping Yee f44c7e8996 Make TextIOWrapper's seek/tell work properly with stateful decoders;
document and rename things to make seek/tell workings a little clearer.

Add a weird decoder for testing TextIOWrapper's seek/tell methods.

Document the getstate/setstate protocol conventions for IncrementalDecoders.
2008-03-18 04:51:32 +00:00
Ka-Ping Yee ddaa7064ee Patch from jbalogh fixes issue #2282 (misnamed seekable() method). 2008-03-17 20:35:15 +00:00
Alexandre Vassalotti a38f73b1bb Fix issue1753: TextIOWrapper.write writes utf BOM for every string.
Patch by Erick Tryzelaar, with slight modifications by me.
2008-01-07 18:30:48 +00:00
Alexandre Vassalotti 472f07d31a Add unit tests for the newlines property of IncrementalNewlineDecoder. 2008-01-06 00:34:32 +00:00
Guido van Rossum f64db9f6db Fix the rest of issue 1400, by introducing a proper implementation of
line buffering.  The TextIOWrapper class no longer calls isatty() on
every write() call.
2007-12-06 01:04:26 +00:00
Christian Heimes ecda261f59 You are right, Guido. The newline argument is easier to use. 2007-12-05 17:59:44 +00:00
Christian Heimes 2ca76f693c Fixed line separator problem on Windows 2007-12-05 13:24:28 +00:00
Guido van Rossum e7fc50f2d0 Add an errors parameter to open() and TextIOWrapper() to specify error handling. 2007-12-03 22:54:21 +00:00
Guido van Rossum 254348e201 Rename buffer -> bytearray. 2007-11-21 19:29:53 +00:00
Amaury Forgeot d'Arc 1ff9910f59 Issue1395: Universal mode used to duplicate newlines when using read(1).
"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
2007-11-19 20:34:10 +00:00
Christian Heimes 8e42a0a0e0 Fixed bug #1081: file.seek allows float arguments 2007-11-08 18:04:45 +00:00
Guido van Rossum 98297ee781 Merging the py3k-pep3137 branch back into the py3k branch.
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.
2007-11-06 21:34:58 +00:00
Guido van Rossum 2dced8b602 Patch 1329 (partial) by Christian Heimes.
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.)
2007-10-30 17:27:30 +00:00
Georg Brandl bd1c68c94f Patch #1303: Adapt str8 constructor to bytes (now buffer) one. 2007-10-24 18:55:37 +00:00
Guido van Rossum bae07c9baf Breaking ground for PEP 3137 implementation:
Get rid of buffer().  Use memoryview() in its place where possible.
In a few places, do things a bit different, because memoryview()
can't slice (yet).
2007-10-08 02:46:15 +00:00
Guido van Rossum 1f2ca56e29 Changes in anticipation of stricter str vs. bytes enforcement. 2007-08-27 20:44:15 +00:00
Guido van Rossum 5abbf750a2 Changes to io.py and socket.py by Christian Heimes.
- 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).
2007-08-27 17:39:33 +00:00
Guido van Rossum 39478e8528 Changes in anticipation of stricter str vs. bytes enforcement. 2007-08-27 17:23:59 +00:00
Guido van Rossum 1836358c01 Fix an unfinished though in my own test code.
(testNewlinesInput and testNewlinesOutput are mine, not Tony's.)
2007-08-18 22:05:58 +00:00
Guido van Rossum 8358db22fa New I/O code from Tony Lownds implement newline feature correctly,
and implements .newlines attribute in a 2.x-compatible fashion.
2007-08-18 21:39:55 +00:00
Guido van Rossum 48fc58ad31 Accellerate binary readline() a bit. 2007-06-07 23:45:37 +00:00
Guido van Rossum c2f93dc2e4 Remove native popen() and fdopen(), replacing them with subprocess calls.
Fix a path to an assert in fileio_read().
Some misc tweaks.
2007-05-24 00:50:02 +00:00
Guido van Rossum 2b08b38dea Fix a few places where a str instead of a bytes object was used. 2007-05-08 20:18:39 +00:00
Guido van Rossum 805365ee39 Merged revisions 55007-55179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk

........
  r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines

  Use the new print syntax, at least.
........
  r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line

  remove old cruftiness
........
  r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line

  make this work with the new Python
........
  r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line

  Get asdl code gen working with Python 2.3.  Should continue to work with 3.0
........
  r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line

  Verify checkins to p3yk (sic) branch go to 3000 list.
........
  r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line

  Fix this test so it runs again by importing warnings_test properly.
........
  r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines

  So long xrange.  range() now supports values that are outside
  -sys.maxint to sys.maxint.  floats raise a TypeError.

  This has been sitting for a long time.  It probably has some problems and
  needs cleanup.  Objects/rangeobject.c now uses 4-space indents since
  it is almost completely new.
........
  r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines

  Fix two tests that were previously depending on significant spaces
  at the end of a line (and before that on Python 2.x print behavior
  that has no exact equivalent in 3.0).
........
2007-05-07 22:24:25 +00:00
Guido van Rossum ef87d6ed94 Rip out all the u"..." literals and calls to unicode(). 2007-05-02 19:09:54 +00:00
Guido van Rossum d76e7796c9 Instead of pickling the whole decoder, use the new getstate/setstate API. 2007-04-17 02:38:04 +00:00
Guido van Rossum dc0b1a1069 Make a few more tests pass with the new I/O library.
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).
2007-04-12 22:55:07 +00:00
Guido van Rossum d410395ea7 Make sure that writing an array instance returns the number of bytes,
not the number of array elements.
2007-04-12 05:44:49 +00:00
Guido van Rossum d0712817ac Re-enable cleanup code. 2007-04-11 16:32:43 +00:00
Guido van Rossum b9c4c3e455 Speed up next() by disabling snapshot updating then. 2007-04-11 16:07:50 +00:00
Guido van Rossum cba608cadb More efficient implementation of tell(); _read_chunk() doesn't have to
call self.buffer.tell().
2007-04-11 14:19:59 +00:00
Guido van Rossum 9b76da6a8f Checkpoint so I can continue to work on this at a different box.
There is somewhat working (but slow) code supporting seek/tell for text files,
but extensive testing exposes a bug I can't nail down.
2007-04-11 01:09:03 +00:00
Guido van Rossum 8742977b33 truncate() returns the new size and position.
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__.
2007-04-10 21:06:59 +00:00
Guido van Rossum 34d69e57e3 Skip large file tests on Windowns and OSX.
Reduce large file size to 2**31 (and a bit).
2007-04-10 20:08:41 +00:00
Guido van Rossum 53807dabf0 Implement long positioning (Unix only, probably).
Etc., etc.
2007-04-10 19:01:47 +00:00
Guido van Rossum 141f767d46 More cleanup. Renamed BlockingIO to BlockingIOError.
Removed unused _PyFileIO class.
Changed inheritance structure.
TODO: do the same kinds of things to TextIO.
2007-04-10 00:22:16 +00:00
Guido van Rossum 76c5d4d72d Checkpoint.
Some cleanup of test_io.py and io.py.
Added seeking to buffered reader and writer, but no tests yet.
2007-04-06 19:10:29 +00:00
Guido van Rossum 78892e4613 Added a working Text I/O layer, by Mark Russell.
This is essentially a checkpoint.
2007-04-06 17:31:18 +00:00
Guido van Rossum a9e2024b84 Check in Daniel Stutzbach's _fileio.c and test_fileio.py
(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.
2007-03-08 00:43:48 +00:00
Guido van Rossum 4d0f5a4934 Delete TESTFN after the test. 2007-03-07 22:59:39 +00:00
Guido van Rossum 00efeadbcf Change the specs for readinto() -- it should *not* shorten the buffer to
the amount of data read.
2007-03-07 05:23:25 +00:00
Guido van Rossum 01a2752d19 New version from Mike Verdone (sat in my inbox since 2/27).
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.
2007-03-07 01:00:12 +00:00
Guido van Rossum 68bbcd2a71 Mike Verdone's checkpoint, cleaned up.
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.
2007-02-27 17:19:33 +00:00
Guido van Rossum 28524c7f10 Checkpoint for new I/O library. 2007-02-27 05:47:44 +00:00