summaryrefslogtreecommitdiffstats
path: root/Modules/_io
Commit message (Collapse)AuthorAgeFilesLines
* gh-82052: Don't send partial UTF-8 sequences to the Windows API (GH-101103)Miss Islington (bot)2023-01-171-1/+16
| | | | | | Don't send partial UTF-8 sequences to the Windows API (cherry picked from commit f34176b77f222726d901595968a4b44456186da4) Co-authored-by: Paul Moore <p.f.moore@gmail.com>
* [3.10] bpo-31718: Fix io.IncrementalNewlineDecoder SystemErrors and s… ↵Kumar Aditya2022-11-281-13/+21
| | | | | | | | | | | | (#99842) [3.10] bpo-31718: Fix io.IncrementalNewlineDecoder SystemErrors and segfaults (GH-18640) Co-authored-by: Oren Milman <orenmn@gmail.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>. (cherry picked from commit 53eef27133c1da395b3b4d7ce0ab1d5b743ffb41) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-38031: Fix a possible assertion failure in _io.FileIO() (GH-GH-5688)Miss Islington (bot)2022-11-251-1/+5
| | | | | (cherry picked from commit d386115039e75c332c8471c239cf7dc5dee791a7) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* gh-83004: Clean up refleak in _io initialisation (GH-98840)Miss Islington (bot)2022-11-031-3/+3
| | | | | (cherry picked from commit 1208037246eeab4c5c003f1651edfefb045e6fb7) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* Fix typo in _io.TextIOWrapper Clinic input (GH-94037) (GH-94117)Miss Islington (bot)2022-06-221-2/+2
| | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit ca308c13daa722f3669a14f1613da768086beb6a) Co-authored-by: fikotta <81991278+fikotta@users.noreply.github.com>
* gh-84461: Silence some compiler warnings on WASM (GH-93978) (#94025)Victor Stinner2022-06-201-1/+1
| | | | | (cherry picked from commit 774ef28814d0d9d57ec813cb31b0a7af6c476127) Co-authored-by: Christian Heimes <christian@python.org>
* bpo-25415: Remove confusing sentence from IOBase docstrings (PR-31631)Miss Islington (bot)2022-03-042-3/+2
| | | | | (cherry picked from commit cedd2473a9bebe07f3ced4f341cf58a2fef07b03) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
* bpo-44687: Ensure BufferedReader objects with unread buffers can peek even ↵Miss Islington (bot)2021-10-011-3/+5
| | | | | | | when the underlying file is closed (GH-28457) (cherry picked from commit a450398933d265011e1e8eae7f771b70f97945fb) Co-authored-by: AngstyDuck <solsticedante@gmail.com>
* bpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection ↵Segev Finer2021-04-232-73/+73
| | | | | | | | (GH-1927) This works by not caching the handle and instead getting the handle from the file descriptor each time, so that if the actual handle changes by fd redirection closing/opening the console handle beneath our feet, we will keep working correctly.
* bpo-43510: Fix emitting EncodingWarning from _io module. (GH-25146)Inada Naoki2021-04-022-13/+17
| | | I forget to check PyErr_WarnEx() return value. But it will fail when -Werror is used.
* Revert "bpo-43510: PEP 597: Accept `encoding="locale"` in binary mode ↵Inada Naoki2021-03-311-2/+1
| | | | | (GH-25103)" (#25108) This reverts commit ff3c9739bd69aa8b58007e63c9e40e6708b4761e.
* bpo-43510: PEP 597: Accept `encoding="locale"` in binary mode (GH-25103)Inada Naoki2021-03-311-1/+2
| | | | It make `encoding="locale"` usable everywhere `encoding=None` is allowed.
* bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)Inada Naoki2021-03-293-1/+99
| | | | | | | | | | | See [PEP 597](https://www.python.org/dev/peps/pep-0597/). * Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`. * Add EncodingWarning * Add io.text_encoding() * open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled. * _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python) * bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding(). * What's new entry
* bpo-43260: io: Prevent large data remains in textio buffer. (GH-24592)Inada Naoki2021-02-211-3/+17
| | | | | | | | When very large data remains in TextIOWrapper, flush() may fail forever. So prevent that data larger than chunk_size is remained in TextIOWrapper internal buffer. Co-Authored-By: Eryk Sun
* bpo-42236: Enhance _locale._get_locale_encoding() (GH-23083)Victor Stinner2020-11-011-1/+1
| | | | | | | | | * Rename _Py_GetLocaleEncoding() to _Py_GetLocaleEncodingObject() * Add _Py_GetLocaleEncoding() which returns a wchar_t* string to share code between _Py_GetLocaleEncodingObject() and config_get_locale_encoding(). * _Py_GetLocaleEncodingObject() now decodes nl_langinfo(CODESET) from the current locale encoding with surrogateescape, rather than using UTF-8.
* bpo-42208: Add _Py_GetLocaleEncoding() (GH-23050)Victor Stinner2020-10-313-48/+4
| | | | | | | | _io.TextIOWrapper no longer calls getpreferredencoding(False) of _bootlocale to get the locale encoding, but calls _Py_GetLocaleEncoding() instead. Add config_get_fs_encoding() sub-function. Reorganize also config_get_locale_encoding() code.
* bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)Victor Stinner2020-10-272-8/+12
| | | | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory. _cursesmodule.c and zoneinfo.c are now built with Py_BUILD_CORE_MODULE macro defined.
* bpo-40170: Use inline _PyType_HasFeature() function (GH-22375)Victor Stinner2020-09-231-1/+2
| | | | | Use _PyType_HasFeature() in the _io module and in structseq implementation. Replace PyType_HasFeature() opaque function call with _PyType_HasFeature() inlined function.
* bpo-36346: Make using the legacy Unicode C API optional (GH-21437)Serhiy Storchaka2020-07-101-0/+12
| | | | Add compile time option USE_UNICODE_WCHAR_CACHE. Setting it to 0 makes the interpreter not using the wchar_t cache and the legacy Unicode C API.
* closes bpo-28557: error message for bad raw readinto (GH-7496)David Szotten2020-06-151-0/+9
| | | Co-authored-by: Benjamin Peterson <benjamin@python.org>
* bpo-40898: Remove redundant if statements in tp_traverse (GH-20692)Hai Shi2020-06-071-3/+1
|
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-286-16/+16
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-2610-139/+8
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-40521: Add PyInterpreterState.unicode (GH-20081)Victor Stinner2020-05-131-1/+1
| | | | | | | Move PyInterpreterState.fs_codec into a new PyInterpreterState.unicode structure. Give a name to the fs_codec structure and use this structure in unicodeobject.c.
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-158-10/+9
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-1/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-142-2/+2
|
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-141-1/+1
| | | | | | | Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET() for consistency with _PyThreadState_GET() and to have a shorter name (help to fit into 80 columns). Add also "assert(tstate != NULL);" to the function.
* bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)Victor Stinner2020-04-133-5/+4
| | | | | | | | Don't access PyInterpreterState.config member directly anymore, but use new functions: * _PyInterpreterState_GetConfig() * _PyInterpreterState_SetConfig() * _Py_GetConfig()
* bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. ↵Serhiy Storchaka2020-04-122-3/+3
| | | | (GH-19472)
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode ↵Serhiy Storchaka2020-04-111-5/+5
| | | | data. (GH-19345)
* bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)Victor Stinner2020-03-251-5/+4
|
* bpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)Dong-hee Na2020-03-241-20/+16
| | | | | | Update _asyncio, _bz2, _csv, _curses, _datetime, _io, _operator, _pickle, _queue, blake2, multibytecodec and overlapped C extension modules to use PyModule_AddType().
* bpo-39968: Convert extension modules' macros of get_module_state() to inline ↵Hai Shi2020-03-161-4/+11
| | | | functions (GH-19017)
* bpo-39674: Revert "bpo-37330: open() no longer accept 'U' in file mode ↵Victor Stinner2020-03-042-3/+29
| | | | | | | (GH-16959)" (GH-18767) This reverts commit e471e72977c83664f13d041c78549140c86c92de. The mode will be removed from Python 3.10.
* bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)Andy Lester2020-03-043-15/+15
|
* bpo-35950: Raise UnsupportedOperation in BufferedReader.truncate() (GH-18586)Berker Peksag2020-02-211-5/+9
| | | | | | | | | | | | | | | The truncate() method of io.BufferedReader() should raise UnsupportedOperation when it is called on a read-only io.BufferedReader() instance. https://bugs.python.org/issue35950 Automerge-Triggered-By: @methane
* bpo-39573: Update clinic to use Py_IS_TYPE() function (GH-18507)Dong-hee Na2020-02-141-2/+2
|
* closes bpo-39605: Fix some casts to not cast away const. (GH-18453)Andy Lester2020-02-121-2/+2
| | | | | | | | | | | | | | | gcc -Wcast-qual turns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either: Adding the const to the type cast, as in: - return _PyUnicode_FromUCS1((unsigned char*)s, size); + return _PyUnicode_FromUCS1((const unsigned char*)s, size); or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in: - PyDTrace_FUNCTION_ENTRY((char *)filename, (char *)funcname, lineno); + PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno); These changes will not change code, but they will make it much easier to check for errors in consts
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-114-45/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)Victor Stinner2020-02-072-2/+2
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* closes bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18295)Philipp Gesang2020-02-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | When called on a closed object, readinto() segfaults on account of a write to a freed buffer: ==220553== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==220553== Access not within mapped region at address 0x2A ==220553== at 0x48408A0: memmove (vg_replace_strmem.c:1272) ==220553== by 0x58DB0C: _buffered_readinto_generic (bufferedio.c:972) ==220553== by 0x58DCBA: _io__Buffered_readinto_impl (bufferedio.c:1053) ==220553== by 0x58DCBA: _io__Buffered_readinto (bufferedio.c.h:253) Reproducer: reader = open ("/dev/zero", "rb") _void = reader.read (42) reader.close () reader.readinto (bytearray (42)) ### BANG! The problem exists since 2012 when commit dc469454ec added code to free the read buffer on close(). Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
* Revert "remove a strange non-ASCII character in _iomodule.c" (GH-17240)Tal Einat2019-11-181-1/+1
| | | | This reverts commit bcc1cc5c, which removed an intentionally placed "form feed" character.
* remove a strange non-ASCII character in _iomodule.c (GH-17239)Tal Einat2019-11-181-1/+1
|
* closes bpo-27805: Ignore ESPIPE in initializing seek of append-mode files. ↵Benjamin Peterson2019-11-121-9/+15
| | | | | (GH-17112) This change, which follows the behavior of C stdio's fdopen and Python 2's file object, allows pipes to be opened in append mode.
* bpo-37330: open() no longer accept 'U' in file mode (GH-16959)Victor Stinner2019-10-282-29/+3
| | | | | open(), io.open(), codecs.open() and fileinput.FileInput no longer accept "U" ("universal newline") in the file mode. This flag was deprecated since Python 3.3.
* bpo-11410: Standardize and use symbol visibility attributes across POSIX and ↵Vinay Sajip2019-10-152-2/+4
| | | | Windows. (GH-16347)
* bpo-37206: Unrepresentable default values no longer represented as None. ↵Serhiy Storchaka2019-09-144-12/+12
| | | | | | | (GH-13933) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all.
* bpo-15999: Clean up of handling boolean arguments. (GH-15610)Serhiy Storchaka2019-09-013-11/+13
| | | | | | * Use the 'p' format unit instead of manually called PyObject_IsTrue(). * Pass boolean value instead 0/1 integers to functions that needs boolean. * Convert some arguments to boolean only once.
* Fix typos mostly in comments, docs and test names (GH-15209)Min ho Kim2019-08-302-2/+2
|