Commit Graph

326 Commits

Author SHA1 Message Date
Antoine Pitrou c644e7c39f Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a flush() on the underlying binary stream.
Patch by akira.
2014-05-09 00:24:50 +02:00
Antoine Pitrou b8503896ad Issue #21057: TextIOWrapper now allows the underlying binary stream's read() or read1() method to return an arbitrary bytes-like object (such as a memoryview).
Patch by Nikolaus Rath.
2014-04-29 10:14:02 +02:00
Andrew Kuchling 764662020b #15840: make docs consistent by saying operations on closed files raise ValueError.
Patch by Caelyn McAulay.

Neither Caelyn nor I could find any cases in 2.7 or 3.4/5 where an
operation on a closed stream raised IOError; generally the C
implementations have a macro to check for the stream being closed, and
these macros all raised ValueError.  If we find any, a new bug should
be opened.
2014-04-15 21:11:36 -04:00
Georg Brandl 2fc8f773e1 Issue #20404: reject non-text encodings early in TextIOWrapper. 2014-03-02 09:18:31 +01:00
Serhiy Storchaka 5bdfc51950 Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
2014-02-12 10:55:07 +02:00
Serhiy Storchaka 61e2493b83 Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
2014-02-12 10:52:35 +02:00
Nick Coghlan a9b15241c6 Close #20404: blacklist non-text encodings in io.TextIOWrapper
- io.TextIOWrapper (and hence the open() builtin) now use the
  internal codec marking system added for issue #19619
- also tweaked the C code to only look up the encoding once,
  rather than multiple times
- the existing output type checks remain in place to deal with
  unmarked third party codecs.
2014-02-04 22:11:18 +10:00
Antoine Pitrou 712cb734bd Issue #20037: Avoid crashes when doing text I/O late at interpreter shutdown. 2013-12-21 15:51:54 +01:00
Serhiy Storchaka 6787a3806e Issue #15204: Deprecated the 'U' mode in file-like objects. 2013-11-23 22:12:06 +02:00
Victor Stinner 3f36a5736b Issue #19515: Remove identifiers duplicated in the same file.
Patch written by Andrei Dorian Duma.
2013-11-12 21:39:02 +01:00
Victor Stinner aa5bbfaa77 Issue #19437: Fix _io._IOBase.close(), handle _PyObject_SetAttrId() failure 2013-11-08 00:29:41 +01:00
Victor Stinner d9d0419a9f Issue #19512: fileio_init() reuses PyId_name identifier instead of "name"
literal string
2013-11-06 23:50:10 +01:00
Victor Stinner cc024d1820 Issue #18408: Fix iobase_readline(), handle PyByteArray_Resize() failure 2013-10-29 02:23:46 +01:00
Antoine Pitrou 4d397008cd Issue #19356: Avoid using a C variabled named "_self", it's a reserved word in some C compilers. 2013-10-23 19:21:55 +02:00
Antoine Pitrou 09fcb72048 Issue #19356: Avoid using a C variabled named "_self", it's a reserved word in some C compilers. 2013-10-23 19:20:21 +02:00
Antoine Pitrou fd4722cacf Issue #9548: Add a minimal "_bootlocale" module that is imported by the _io module instead of the full locale module. 2013-10-12 00:13:50 +02:00
Antoine Pitrou e619427f7e Issue #18876: The FileIO.mode attribute now better reflects the actual mode under which the file was opened.
Patch by Erik Bray.
2013-09-04 20:52:14 +02:00
Antoine Pitrou e93b63b74b Issue #18876: The FileIO.mode attribute now better reflects the actual mode under which the file was opened.
Patch by Erik Bray.
2013-09-04 20:46:33 +02:00
Victor Stinner daf455554b Issue #18571: Implementation of the PEP 446: file descriptors and file handles
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
2013-08-28 00:53:59 +02:00
Serhiy Storchaka edd0de58a8 Issue #13461: Fix a crash in the TextIOWrapper.tell method on 64-bit platforms.
Patch by Yogesh Chaudhari.
2013-08-20 20:07:50 +03:00
Serhiy Storchaka ec67d187ee Issue #13461: Fix a crash in the TextIOWrapper.tell method on 64-bit platforms.
Patch by Yogesh Chaudhari.
2013-08-20 20:04:47 +03:00
Antoine Pitrou 932ff83682 Issue #18608: Avoid keeping a strong reference to the locale module inside the _io module. 2013-08-01 21:04:50 +02:00
Christian Heimes 72f455e96c Fix use of uninitialized scalar variable, see 3f994367a979
CID 1058763
2013-07-31 01:33:50 +02:00
Antoine Pitrou 796564c27b Issue #18112: PEP 442 implementation (safe object finalization). 2013-07-30 19:59:21 +02:00
Victor Stinner ace47d7efd Issue #18408: PyEval_EvalFrameEx() and PyEval_CallObjectWithKeywords() now fail
with an assertion error if they are called with an exception set
(PyErr_Occurred()).

If these functions are called with an exception set, the exception may be
cleared and so the caller looses its exception.

Add also assertions to PyEval_CallObjectWithKeywords() and call_function() to
check if the function succeed with no exception set, or the function failed
with an exception set.
2013-07-18 01:41:08 +02:00
Victor Stinner 85c761d3d3 Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure
bytes is NULL on _PyBytes_Resize() failure
2013-07-16 21:36:02 +02:00
Richard Oudkerk 9ba6962a04 Issue #18344: Fix potential ref-leaks in _bufferedreader_read_all(). 2013-07-15 16:10:28 +01:00
Richard Oudkerk 9ad51ec81b Issue #18344: Fix potential ref-leaks in _bufferedreader_read_all(). 2013-07-15 16:05:22 +01:00
Victor Stinner 14b9b11098 If MS_WIN64 is defined, MS_WINDOWS is also defined: #ifdef can be simplified. 2013-06-25 00:37:25 +02:00
Victor Stinner 9a282975ef Issue #9566: _io: Use Py_SAFE_DOWNCAST for fix a compiler warning on Windows x64 2013-06-24 23:01:33 +02:00
Christian Heimes 9975877f46 Check for correct macro, code uses S_ISDIR(). 2013-06-23 23:52:40 +02:00
Christian Heimes 91e8b8180d Check for correct macro, code uses S_ISDIR(). 2013-06-23 23:51:44 +02:00
Andrew Kuchling f567727abc Merge with 3.3 2013-06-16 13:02:55 -04:00
Andrew Kuchling c7b6c50f29 Describe 'surrogateescape' in the documentation.
Also, improve some docstring descriptions of the 'errors' parameter.

Closes #14015.
2013-06-16 12:58:48 -04:00
Serhiy Storchaka 37a79a12d1 Issue #18025: Fixed a segfault in io.BufferedIOBase.readinto() when raw
stream's read() returns more bytes than requested.
2013-05-28 16:24:45 +03:00
Serhiy Storchaka 281945f427 Issue #18025: Fixed a segfault in io.BufferedIOBase.readinto() when raw
stream's read() returns more bytes than requested.
2013-05-28 16:27:08 +03:00
Victor Stinner 3e269397e3 FileIO.readall(): remove trailing space from an exception message 2013-05-18 00:38:43 +02:00
Richard Oudkerk af7260e81a Issue #15758: Fix FileIO.readall() so it no longer has O(n**2) complexity. 2013-05-17 23:34:42 +01:00
Terry Jan Reedy 16c41d8520 Merge 3.3, issue #17047: remove doubled words found in 2.7 to 3.4
Modules/*, as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 17:46:07 -04:00
Terry Jan Reedy 09b7503bc9 Merge 3.2, Issue #17047: remove doubled words found in 2.7 to 3.4
Modules/*, as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 17:45:12 -04:00
Terry Jan Reedy 0158af38b7 Issue #17047: remove doubled words found in 2.7 to 3.4 Modules/*,
as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 17:42:46 -04:00
R David Murray d7c59e101f Merge #17275: Fix class name in init errors in C bufferedio classes.
This fixes an apparent copy-and-paste error.

Patch by Manuel Jacob.
2013-02-23 22:21:48 -05:00
R David Murray 9f10f56d13 Merge #17275: Fix class name in init errors in C bufferedio classes.
This fixes an apparent copy-and-paste error.

Patch by Manuel Jacob.
2013-02-23 22:07:55 -05:00
R David Murray 67bfe80758 #17275: Fix class name in init errors in C bufferedio classes.
This fixes an apparent copy-and-paste error.

Patch by Manuel Jacob.
2013-02-23 21:51:05 -05:00
Serhiy Storchaka cce1b8eda8 Issue #17106: Fix a segmentation fault in io.TextIOWrapper when an underlying
stream or a decoder produces data of an unexpected type (i.e. when
io.TextIOWrapper initialized with text stream or use bytes-to-bytes codec).
2013-02-03 17:09:17 +02:00
Serhiy Storchaka d03ce4ae3d Issue #17106: Fix a segmentation fault in io.TextIOWrapper when an underlying
stream or a decoder produces data of an unexpected type (i.e. when
io.TextIOWrapper initialized with text stream or use bytes-to-bytes codec).
2013-02-03 17:07:32 +02:00
Serhiy Storchaka 94dc6736bd Issue #17106: Fix a segmentation fault in io.TextIOWrapper when an underlying
stream or a decoder produces data of an unexpected type (i.e. when
io.TextIOWrapper initialized with text stream or use bytes-to-bytes codec).
2013-02-03 17:03:31 +02:00
Gregory P. Smith 84d0bf94b0 Additional fix for issue #12268: The io module file object write methods no
longer abort early when a write system call is interrupted (EINTR).
2013-02-01 13:10:33 -08:00
Gregory P. Smith 99ec7f6f3e Additional fix for issue #12268: The io module file object write methods no
longer abort early when a write system call is interrupted (EINTR).
2013-02-01 13:08:23 -08:00
Gregory P. Smith b9817b01ed Additional fix for Issue #12268: The io module file object writelines() methods no longer abort early when one of its write system calls is interrupted (EINTR). 2013-02-01 13:03:39 -08:00
Serhiy Storchaka 441d30fac7 Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:26:26 +02:00
Serhiy Storchaka 9101e23ff6 Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:41:45 +02:00
Serhiy Storchaka 7898043868 Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.
2013-01-15 01:12:17 +02:00
Victor Stinner fd53a5a011 (Merge 3.3) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. 2013-01-03 03:38:38 +01:00
Victor Stinner 6f84659e5e (Merge 3.2) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. 2013-01-03 03:37:47 +01:00
Victor Stinner c44057dfbd Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB 2013-01-03 03:33:21 +01:00
Benjamin Peterson 4c05969fc4 merge 3.3 (#16597) 2012-12-20 11:55:16 -06:00
Benjamin Peterson 68623614f0 call close on the underlying stream even if flush raises (closes #16597)
Patch by Serhiy Storchaka.
2012-12-20 11:53:11 -06:00
Andrew Svetlov a191959849 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:27:16 +02:00
Andrew Svetlov 5b89840d9c Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:26:36 +02:00
Andrew Svetlov 737fb89dd1 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:14:22 +02:00
Victor Stinner 292c835548 Issue #15478: Raising an OSError doesn't decode or encode the filename anymore
Pass the original filename argument to OSError constructor, instead of trying
to encode it to or decode it from the filesystem encoding. This change avoids
an additionnal UnicodeDecodeError on Windows if the filename cannot be decoded
from the filesystem encoding (ANSI code page).
2012-10-30 02:17:38 +01:00
Christian Heimes 743e0cd6b5 Issue #16166: Add PY_LITTLE_ENDIAN and PY_BIG_ENDIAN macros and unified
endianess detection and handling.
2012-10-17 23:52:17 +02:00
Jesus Cea dc469454ec Closes #15488: Closed files keep their buffer alive 2012-10-04 12:37:56 +02:00
Ezio Melotti 6d10b4d591 #15796: merge with 3.2. 2012-09-18 07:21:18 +03:00
Ezio Melotti 16d2b47837 #15796: Fix \n in readline docstring. Patch by Serhiy Storchaka. 2012-09-18 07:20:18 +03:00
Christian Heimes f47d79fec1 Fixed reference leak in error branch of _bufferedreader_read_all(). The variable data can contain a bytes object but it wasn't cleaned up when PyList_New() failed. CID 715364 2012-09-10 17:46:09 +02:00
Christian Heimes 89ff3c7f20 Fixed out-of-bounce write to rawmode buffer. The fixed size buffer wasn't enlarged for the new 'x' flag. The buffer may contain the 5 flags xrwa+ and the \0 byte 2012-09-10 03:50:48 +02:00
Stefan Krah ea94ba45fa Merge 3.2. 2012-09-08 11:19:27 +02:00
Stefan Krah 96efdd422c Issue #15868: Fix refleak in bytesio.c (Coverity #715365). 2012-09-08 11:12:33 +02:00
Antoine Pitrou 11946fbe80 Issue #15841: The readable(), writable() and seekable() methods of BytesIO
and StringIO objects now raise ValueError when the object has been closed.
Patch by Alessandro Moura.
2012-09-05 20:13:48 +02:00
Antoine Pitrou 1d857453b7 Issue #15841: The readable(), writable() and seekable() methods of BytesIO
and StringIO objects now raise ValueError when the object has been closed.
Patch by Alessandro Moura.
2012-09-05 20:11:49 +02:00
Antoine Pitrou 721738fbee Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
2012-08-15 23:20:39 +02:00
Antoine Pitrou 6f430e4963 Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
2012-08-15 23:18:25 +02:00
Victor Stinner d1f9352bd4 (Merge 3.2) open() / TextIOWrapper doc: make it explicit than newline='\n'
doesn't translate newlines on output.
2012-08-04 01:22:07 +02:00
Victor Stinner 401e17d0f0 open() / TextIOWrapper doc: make it explicit than newline='\n' doesn't
translate newlines on output.
2012-08-04 01:18:56 +02:00
Antoine Pitrou 3c25dfbf13 Make TextIOWrapper's documentation clearer by copying the newline argument's description from open(). 2012-08-04 00:56:19 +02:00
Antoine Pitrou 0c1c0d42dc Make TextIOWrapper's documentation clearer by copying the newline argument's description from open(). 2012-08-04 00:55:38 +02:00
Antoine Pitrou 57911f6c1a Issue #15489: Add a __sizeof__ implementation for BytesIO objects.
Patch by Serhiy Storchaka.
2012-07-30 00:01:44 +02:00
Antoine Pitrou 8f328d0c1d Issue #15489: Add a __sizeof__ implementation for BytesIO objects.
Patch by Serhiy Storchaka.
2012-07-30 00:01:06 +02:00
Antoine Pitrou a264384fe6 Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
Patch by Serhiy Storchaka.
2012-07-29 19:04:57 +02:00
Antoine Pitrou 10f0c50a0b Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
Patch by Serhiy Storchaka.
2012-07-29 19:02:46 +02:00
Florent Xicluna 109d57358e Issue #13248: io: Remove obsolete argument "max_buffer_size" of BufferedWriter and BufferedRWPair. 2012-07-07 17:03:22 +02:00
Antoine Pitrou 7d7f40c613 Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory. 2012-07-06 18:52:58 +02:00
Antoine Pitrou 9235b254dc Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory. 2012-07-06 18:48:24 +02:00
Gregory P. Smith 990a5feba7 Fixes issue #12268: File readline, readlines and read() or readall() methods
no longer lose data when an underlying read system call is interrupted.
IOError is no longer raised due to a read system call returning EINTR
from within these methods.
2012-06-24 00:23:47 -07:00
Gregory P. Smith 5135992164 Fixes issue #12268: File readline, readlines and read() or readall() methods
no longer lose data when an underlying read system call is interrupted.
IOError is no longer raised due to a read system call returning EINTR
from within these methods.
2012-06-23 23:55:39 -07:00
Jesus Cea 9436361e4c Closes #10142: Support for SEEK_HOLE/SEEK_DATA 2012-06-22 18:32:07 +02:00
Hynek Schlawack 7f59fd7c7c Simplify code in fileio_init
If an identical code line is in both at the end of if and else, it can as well
stand after the block. :) The code is from 464cf523485e, I didn't see it before
checking the commits in the web interface of course.
2012-06-22 09:32:22 +02:00
Hynek Schlawack 69168354c2 #10053: Don't close FDs when FileIO.__init__ fails
Loosely based on the work by Hirokazu Yamamoto.
2012-06-21 20:58:31 +02:00
Hynek Schlawack 9ed8b4e4ca #10053: Don't close FDs when FileIO.__init__ fails
Loosely based on the work by Hirokazu Yamamoto.
2012-06-21 20:20:25 +02:00
Victor Stinner f86a5e8a93 Close #11022: TextIOWrapper doesn't call locale.setlocale() anymore
open() and io.TextIOWrapper are now calling locale.getpreferredencoding(False)
instead of locale.getpreferredencoding() in text mode if the encoding is not
specified. Don't change temporary the locale encoding using locale.setlocale(),
use the current locale encoding instead of the user preferred encoding.

Explain also in open() documentation that locale.getpreferredencoding(False) is
called if the encoding is not specified.
2012-06-05 13:43:22 +02:00
Hynek Schlawack 9866d96e48 #4841: Fix FileIO constructor to honor closefd when called repeatedly
Patch by Victor Stinner.
2012-05-25 10:27:43 +02:00
Hynek Schlawack 2cc7156515 #4841: Fix FileIO constructor to honor closefd when called repeatedly
Patch by Victor Stinner.
2012-05-25 10:05:53 +02:00
Jesus Cea 990eff0776 Backing out 86dc014cdd74. Not ready yet 2012-04-26 17:05:31 +02:00
Jesus Cea 2b47f0a23f Close #10142: Support for SEEK_HOLE/SEEK_DATA 2012-04-26 16:39:35 +02:00
Antoine Pitrou a3f4457b17 Speed up reading of small files. This avoids multiple C read() calls on pyc files. 2012-04-17 13:50:58 +02:00
Ross Lagerwall 0f9eec19ee Don't Py_DECREF NULL variable in io.IncrementalNewlineDecoder.
Found with Clang's Static Analyzer.
2012-04-07 07:09:57 +02:00
Antoine Pitrou 6211b88161 Issue #14437: Fix building the _io module under Cygwin. 2012-03-31 23:50:31 +02:00
Antoine Pitrou d0acb411ef Issue #14387: Do not include accu.h from Python.h. 2012-03-22 14:42:18 +01:00