Remove functions in string module that are also string methods. Also remove:
* all calls to functions in the string module (except maketrans)
* everything from stropmodule except for maketrans() which is still used
Support name and mode attributes on all file types.
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.
Support marshal.dump(x, f) where f is not a real file.
Support ord(b) where b is a 1-byte string.
In zipfile.py, work around bytes being ints instead of chars, sometimes.
Rough and dirty job -- allow concatenation of bytes and arbitrary
buffer-supporting objects (Unicode always excluded), and also of
str and bytes.
(For some reason u"" + b"" doesn't fail, I'll investigate later.)
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).
An example of action-at-a-distance: fix the problems I had in test_io.py
without touching io.py or test_io.py. The cause of the failure was that
bytes objects didn't pickle right. As a stop-gap measure, I'm providing
bytes pickling via copy_reg. Eventually, we should use a more efficient
protocol, e.g. __reduce_ex__ or __getstate__/__setstate__.
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.
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__.
More cleanup. Renamed BlockingIO to BlockingIOError.
Removed unused _PyFileIO class.
Changed inheritance structure.
TODO: do the same kinds of things to TextIO.
Cleanup.
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.
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.
Collin Winter [Wed, 28 Mar 2007 21:44:53 +0000 (21:44 +0000)]
Make readonly members defined in C throw an AttributeError on modification. This brings them into sync with Python-level attributes. Fixes bug #1687163.
Guido van Rossum [Wed, 28 Mar 2007 21:02:43 +0000 (21:02 +0000)]
Fix errors in bsddb3 tests due to removal of exception slicing.
(There was also a segfault but it disappeared when the tests
stopped erroring out; I presume the segfault is a pre-existing
problem somewhere in a destructor.)
Brett Cannon [Wed, 21 Mar 2007 22:26:20 +0000 (22:26 +0000)]
When removing indexing/slicing on exceptions some places were changed
inappropriately from ``e[0]`` to ``e.message`` instead of ``e.args[0]``. The
reason it needs to be the last option is the dichotomy of 'message' and 'args':
'message' can be the empty string but args[0] can have a value if more than one
argument was passed.
Neal Norwitz [Wed, 21 Mar 2007 04:45:04 +0000 (04:45 +0000)]
Little fixes:
* make some module variables static to prevent name pollution
* Add some comments to clarify what's going on and some XXXs to address
* Add a space after "for" before (
* exc_value and tb can be NULL in some cases
* Get working on Windows (I think)
Guido van Rossum [Mon, 19 Mar 2007 22:26:27 +0000 (22:26 +0000)]
Make test_socket_ssl.py pass by fixing some code that was
incorrectly assuming that err.message was the Py3k way of
writing err[0] in 2.x. The correct spelling is err.args[0].
Guido van Rossum [Sun, 18 Mar 2007 15:41:51 +0000 (15:41 +0000)]
Implement PEP 3115 -- new metaclass syntax and semantics.
The compiler package hasn't been updated yet; test_compiler.py fails.
Otherwise all tests seem to be passing now. There are no occurrences
of __metaclass__ left in the standard library.
Docs have not been updated.
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.