Commit Graph

113 Commits

Author SHA1 Message Date
Zackery Spytz f347c6eb75 bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) (GH-11249)
(cherry picked from commit 842acaab13)
2018-12-20 19:38:52 +02:00
Serhiy Storchaka eab421bff9
[2.7] bpo-25862: Fix several bugs in the _io module. (GH-8026) (GH-8033)
They can be exposed when some C API calls fail due to lack of
memory.

* Failed Py_BuildValue() could cause an assertion error in the
  following TextIOWrapper.tell().
* initvalue could leak in StringIO.__getstate__() after failed
  PyDict_Copy().
(cherry picked from commit fdb5a50ef3)
2018-12-04 12:02:48 +02:00
Miss Islington (bot) 05acd44ad6
bpo-35062: Fix parsing _io.IncrementalNewlineDecoder's *translate* argument. (GH-10217)
_io.IncrementalNewlineDecoder's initializer possibly assigns out-of-range
value to the bitwise struct field.
(cherry picked from commit b08746bfdf)

Co-authored-by: Xiang Zhang <angwerzx@126.com>
2018-10-31 05:37:06 -07:00
Serhiy Storchaka fc153d1279
[2.7] bpo-34068: iobase_close could call PyObject_SetAttrString with an exception set (GH-8282). (GH-8312) (GH-8314)
(cherry picked from commit 28f07364f0)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>.
(cherry picked from commit cc13016658)
2018-07-17 18:15:46 +03:00
Zackery Spytz 0464de0f9a [2.7] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918). (GH-8013)
(cherry picked from commit 23db935bcf)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-29 23:07:13 +03:00
Nir Soffer 830daae1c8 [2.7] bpo-32186: Release the GIL during fstat and lseek calls (#4651)
In fileio, there were 3 fstat() calls and one lseek() call that did not
release the GIL during the call. This can cause all threads to hang for
unlimited time when using io.FileIO with inaccessible NFS server.

Same issue seen in fileio exists also in fileobject, fixed in the same
way.
2017-12-07 21:25:39 +01:00
Serhiy Storchaka 4954b8dc53 [2.7] bpo-25359: Add missed "goto error" after setting an exception. (GH-3712) (#3779)
(cherry picked from commit d6238a76c6)
2017-09-27 08:44:03 +03:00
INADA Naoki 4cde4bdcc8 bpo-31095: Fix potential crash during GC (GH-3197)
(cherry picked from commit a6296d34a4)
2017-09-04 12:31:41 +09:00
Oren Milman 20958e6d91 [2.7] bpo-31243: Fixed PyArg_ParseTuple failure checks. (GH-3171) (#3235) 2017-08-29 19:16:12 +03:00
Serhiy Storchaka 64aa4df850 [2.7] bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (GH-1096) (GH-1180) (#1183)
raised an error.

(cherry picked from commit bf623ae884)
(cherry picked from commit 680fea4)
2017-04-19 22:34:58 +03:00
Xiang Zhang 5fbdfc36f3 bpo-30068: add missing iter(self) in _io._IOBase.readlines when hint is present (#1152) 2017-04-15 13:18:22 +08:00
Martin Panter c7496ee6da Fix spelling and markup in documentation and code comment
* Mark up ``--help`` to avoid generating an en dash
* Use forward slash in Unix command line with a dollar sign ($) prompt
2017-01-14 08:51:49 +00:00
Steve Dower f85dbfc3d2 Issue #28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto 2016-12-28 15:41:09 -08:00
Serhiy Storchaka 52b0888dbd Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
the garbage collector is invoked in other thread.
Based on patch by Sebastian Cufre.
2016-11-03 15:36:50 +02:00
Martin Panter 6507657ddd Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
Martin Panter b362f75f6e Issue #25523: Correct "a" article to "an" article
This changes the main documentation, doc strings, source code comments, and a
couple error messages in the test suite. In some cases the word was removed
to fix the grammar.
2015-11-02 03:37:02 +00:00
Serhiy Storchaka 3c9ce74c21 Issue #23908: os functions, open() and the io.FileIO constructor now reject
unicode paths with embedded null character on Windows instead of silently
truncate them.
2016-07-01 23:34:44 +03:00
Martin Panter c9813d83f7 Issue #20699: Document that “io” methods should accept memoryview
This matches the usage by BufferedReader, BufferedWriter, etc. Also document
and test that the write() methods should only access their argument before
they return.
2016-06-03 05:59:20 +00:00
Benjamin Peterson a48aa85da0 check the result of PyByteArray_Resize in readline() (closes #27211) 2016-06-03 22:20:44 -07:00
Martin Panter 5b48fa9fa4 Fix spelling (inital), grammar (may translates) in documentation, comments 2016-04-19 04:03:41 +00:00
Martin Panter bf02d18844 Fix typos in code comment and documentation 2016-04-16 09:28:57 +00:00
Serhiy Storchaka bc62af1bbe Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:51:18 +03:00
Serhiy Storchaka 8688acaf2e Issue #20440: Applied yet one patch for using Py_SETREF.
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-27 12:38:48 +02:00
Serhiy Storchaka c06a6d0958 Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
2015-12-19 20:07:48 +02:00
Martin Panter dab305ef05 Issue #22413: Document newline effect on StringIO initializer and getvalue
Also add to comment in the C code.
2015-10-10 02:52:30 +00:00
Martin Panter 6f80464f4a Issue #25030: Do not document seek() as if it accepts keyword arguments
Patch from Shiyao Ma.
2015-09-11 03:58:30 +00:00
Serhiy Storchaka c7797dc748 Issue #19543: Emit deprecation warning for known non-text encodings.
Backported issues #19619: encode() and decode() methods and constructors
of str, unicode and bytearray classes now emit deprecation warning for known
non-text encodings when Python is ran with the -3 option.

Backported issues #20404: io.TextIOWrapper (and hence io.open()) now uses the
internal codec marking system added to emit deprecation warning for known non-text
encodings at stream construction time when Python is ran with the -3 option.
2015-05-31 20:21:00 +03:00
Serhiy Storchaka 461295443f Issue #21859: Corrected FileIO docstrings. 2015-04-10 16:08:33 +03:00
Serhiy Storchaka 96d8012964 Issue #23785: Fixed memory leak in TextIOWrapper.tell() in rare circumstances. 2015-03-30 10:00:49 +03:00
Serhiy Storchaka aa64c46ac9 Issue #23781: Add private helper function _PyErr_ReplaceException() that
corresponds _PyErr_ChainExceptions() in Python 3 to help porting patches
from Python 3.
2015-03-30 09:48:42 +03:00
Serhiy Storchaka f95a57f9a1 Issue #21802: The reader in BufferedRWPair now is closed even when closing
writer failed in BufferedRWPair.close().
2015-03-24 23:23:42 +02:00
Serhiy Storchaka 3173f7c904 Issue #5700: io.FileIO() called flush() after closing the file.
flush() was not called in close() if closefd=False.
2015-02-21 00:34:20 +02:00
Benjamin Peterson 53ae6145a0 allow more operations to work on detached streams (closes #23093)
Patch by Martin Panter.
2014-12-21 20:51:50 -06:00
Benjamin Peterson 1c873bf77d clear BufferedRWPair weakrefs on deallocation (closes #22517) 2014-09-29 22:46:57 -04:00
Berker Peksag b5dc3dcb92 Issue #21860: Correct docstrings of FileIO.seek() and FileIO.truncate() methods.
Patch by Terry Chia.
2014-09-24 12:54:25 +03:00
Benjamin Peterson a83050196d properly decref the return value of close() 2014-07-04 17:00:25 -07:00
Victor Stinner f6b3c84a4a Issue #21090: io.FileIO.readall() does not ignore I/O errors anymore. Before,
it ignored I/O errors if at least the first C call read() succeed.
2014-07-02 23:12:48 +02:00
Serhiy Storchaka 05b0a1be37 Issue #21310: Fixed possible resource leak in failed open(). 2014-06-09 13:32:08 +03:00
Kristján Valur Jónsson be580f2e48 Issue #20434 Correct error handlin of _PyString_Resize and _PyBytes_Resize 2014-04-25 09:51:21 +00:00
Andrew Kuchling 68e85e5834 #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
implementation 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 16:07:52 -04:00
Serhiy Storchaka 1d19f97eed Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
2014-02-12 10:52:07 +02:00
Antoine Pitrou 213fec4bff 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
Serhiy Storchaka a9885e93ee Issue #13461: Fix a crash in the TextIOWrapper.tell method and in the "replace"
error handler on 64-bit platforms.  Patch by Yogesh Chaudhari.
2013-08-20 20:08:53 +03:00
Terry Jan Reedy ce9cc49104 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:41:44 -04:00
R David Murray 5b2cf5e651 #17275: Fix class name in init errors in C bufferedio classes.
This fixes an apparent copy-and-paste error.

Original patch by Manuel Jacob.
2013-02-23 22:11:21 -05:00
Serhiy Storchaka 354d50ee37 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:10:42 +02:00
Gregory P. Smith a998ad0135 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:02:59 -08:00
Serhiy Storchaka 74f49ab28b Issue #15989: Fix several occurrences of integer overflow
when result of PyInt_AsLong() or PyLong_AsLong() narrowed
to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:55:39 +02:00
Victor Stinner 23a32ba0e5 Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB 2013-01-03 03:33:21 +01:00
Benjamin Peterson a2d6d7121e call close on the underlying stream even if flush raises (#16597) 2012-12-20 12:24:10 -06:00