summaryrefslogtreecommitdiffstats
path: root/Modules/_io
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] gh-119506: fix `_io.TextIOWrapper.write()` write during flush ↵Miss Islington (bot)2024-06-191-9/+22
| | | | | | | | | (GH-119507) (#119965) gh-119506: fix `_io.TextIOWrapper.write()` write during flush (GH-119507) (cherry picked from commit 52586f930f62bd80374f0f240a4ecce0c0238174) Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* [3.12] gh-95782: Fix io.BufferedReader.tell() etc. being able to return ↵Miss Islington (bot)2024-02-171-1/+10
| | | | | | | | | | | | | | | | | | | | | | offsets < 0 (GH-99709) (GH-115599) lseek() always returns 0 for character pseudo-devices like `/dev/urandom` (for other non-regular files, e.g. `/dev/stdin`, it always returns -1, to which CPython reacts by raising appropriate exceptions). They are thus technically seekable despite not having seek semantics. When calling read() on e.g. an instance of `io.BufferedReader` that wraps such a file, `BufferedReader` reads ahead, filling its buffer, creating a discrepancy between the number of bytes read and the internal `tell()` always returning 0, which previously resulted in e.g. `BufferedReader.tell()` or `BufferedReader.seek()` being able to return positions < 0 even though these are supposed to be always >= 0. Invariably keep the return value non-negative by returning max(former_return_value, 0) instead, and add some corresponding tests. (cherry picked from commit 26800cf25a0970d46934fa9a881c0ef6881d642b) Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
* [3.12] gh-115059: Flush the underlying write buffer in ↵Miss Islington (bot)2024-02-091-0/+10
| | | | | | | io.BufferedRandom.read1() (GH-115163) (GH-115205) (cherry picked from commit 846fd721d518dda88a7d427ec3d2c03c45d9fa90) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD ↵Erlend E. Aasland2024-02-066-12/+12
| | | | | methods without params (#115016) (#115067) (cherry picked from commit 09096a1647913526a3d4fa69a9d2056ec82a8f37)
* [3.12] gh-114286: Fix `maybe-uninitialized` warning in ↵Miss Islington (bot)2024-01-191-1/+1
| | | | | | | `Modules/_io/fileio.c` (GH-114287) (GH-114288) (cherry picked from commit 05e47202a34e6ae05e699af1083455f5b8b59496) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-80109: Fix io.TextIOWrapper dropping the internal buffer during ↵Miss Islington (bot)2024-01-081-4/+8
| | | | | | | | | write() (GH-22535) (GH-113808) io.TextIOWrapper was dropping the internal decoding buffer during read() and write() calls. (cherry picked from commit 73c93265634257b1488262097e024c1727260cfd) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* [3.12] gh-111049: Fix crash during garbage collection of the BytesIO buffer ↵Miss Islington (bot)2023-12-141-10/+4
| | | | | | | object (GH-111221) (GH-113096) (cherry picked from commit bb36f72efcc6a656e0907ffa83620a1e44044895) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-111942: Fix SystemError in the TextIOWrapper constructor ↵Victor Stinner2023-11-151-2/+11
| | | | | | | | | | | (GH-112061) (GH-112089) In non-debug more the check for the "errors" argument is skipped, and then PyUnicode_AsUTF8() can fail, but its result was not checked. Co-authored-by: Victor Stinner <vstinner@python.org> (cherry picked from commit 9302f05f9af07332c414b3c19003efd1b1763cf3) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976) ↵Miss Islington (bot)2023-11-141-3/+36
| | | | | | | | | | | | | (GH-112058) * Fix crash when encoding is not string or None. * Fix crash when both line_buffering and write_through raise exception when converted ti int. * Add a number of tests for constructor and reconfigure() method with invalid arguments. (cherry picked from commit ee06fffd38cb51ce1c045da9d8336d9ce13c318a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-111174: Fix crash in getbuffer() called repeatedly for empty ↵Miss Islington (bot)2023-10-251-3/+4
| | | | | | | BytesIO (GH-111210) (GH-111314) (cherry picked from commit 9da98c0d9a7cc55c67fb0bd3fa162fd3b2c2629b) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-110913: Fix WindowsConsoleIO chunking of UTF-8 text (GH-111007)Miss Islington (bot)2023-10-201-16/+20
| | | | | (cherry picked from commit 11312eae6ec3acf51aacafce4cb6d1a5edfd5f2e) Co-authored-by: Tamás Hegedűs <sorgloomer@users.noreply.github.com>
* [3.12] gh-107801: Improve the accuracy of io.IOBase.seek docs (#108268) ↵Erlend E. Aasland2023-08-292-2/+9
| | | | | | | | | | | (#108655) (cherry picked from commit 8178a88bd81edae87d6974483e4de9b32e808797) - Add param docstrings - Link to os.SEEK_* constants - Mention the return value in the initial paragraph Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* [3.12] gh-107801: Document io.TextIOWrapper.tell (#108265) (#108547)Erlend E. Aasland2023-08-272-3/+12
| | | (cherry picked from commit 38afa4af9bfc8297a5ee270c37f3f120a04297ea)
* [3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) ↵Miss Islington (bot)2023-08-262-7/+7
| | | | | | | | | | | | (#108523) gh-107913: Fix possible losses of OSError error codes (GH-107930) Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be called immediately after using the C API which sets errno or the Windows error code. (cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-107801: Improve the accuracy of io.TextIOWrapper.seek docs ↵Erlend E. Aasland2023-08-222-5/+39
| | | | | | | | | | | (#107933) (#108262) (cherry picked from commit 7f87ebbc3f52680c939791f397b9a478edf0c8d4) Clearly document the supported seek() operations: - Rewind to the start of the stream - Restore a previous stream position (given by tell()) - Fast-forward to the end of the stream
* GH-104510: Fix refleaks in `_io` base types (#104516)Kumar Aditya2023-05-163-26/+6
|
* gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization ↵Eric Snow2023-05-151-1/+2
| | | | | (gh-104437) With the move to a per-interpreter GIL, this check slipped through the cracks.
* gh-101819: Fix _io clinic input for unused base class method stubs (#104418)Erlend E. Aasland2023-05-156-109/+168
| | | | | | When preparing the _io extension module for isolation, many methods were adapted to Argument Clinic. Some of these used the '*args: object' signature, which is incorrect. These are now corrected to an exact signature, and marked unused, since they are stub methods.
* gh-101819: Isolate `_io` (#101948)Erlend E. Aasland2023-05-159-346/+198
| | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-101819: Prepare _io._IOBase for module state (#104386)Erlend E. Aasland2023-05-124-11/+21
| | | | - Add PyIOBase_Type to _io module state - Pass defining class to _io._IOBase.fileno
* gh-101819: Fix inverted debug preprocessor check in winconsoleio.c (#104388)Erlend E. Aasland2023-05-111-1/+1
|
* gh-101819: Adapt _io.IOBase.seek and _io.IOBase.truncate to Argument Clinic ↵Erlend E. Aasland2023-05-112-22/+135
| | | | (#104384)
* gh-101819: Adapt _io._Buffered* methods to Argument Clinic (#104367)Erlend E. Aasland2023-05-112-56/+328
|
* gh-101819: Refactor `_io` futher in preparation for module isolation (#104369)Erlend E. Aasland2023-05-115-116/+268
|
* gh-101819: Adapt _io.TextIOBase methods to Argument Clinic (#104383)Erlend E. Aasland2023-05-112-40/+233
|
* gh-101819: Adapt _io._BufferedIOBase_Type methods to Argument Clinic (#104355)Erlend E. Aasland2023-05-102-44/+236
| | | | Make sure the defining class is passed to all methods, so we can easily fetch module state from them in the future.
* gh-101819: Clean up _io windows console io after gh-104197 (#104354)Erlend E. Aasland2023-05-103-3/+3
|
* gh-101819: Harden _io init (#104352)Erlend E. Aasland2023-05-101-3/+4
| | | Fix potential refleak if PyModule_AddObject() fails.
* gh-101819: Refactor _io in preparation for module isolation (#104334)Erlend E. Aasland2023-05-093-42/+80
| | | | | | | | | | - Replace query with parameter in bufferediobase_unsupported() - Replace query with parameter in iobase_unsupported() - Hide delegate: Add method wrapper for _PyIOBase_check_seekable - Hide delegate: Add method wraper for _PyIOBase_check_readable - Hide delegate: Add method wraper for _PyIOBase_check_writable - Replace query with parameter in _PyIOBase_check_seekable() - Replace query with parameter in _PyIOBase_check_readable() - Replace query with parameter in _PyIOBase_check_writable()
* gh-101819: Port _io.PyBytesIOBuffer_Type to heap type (#104264)Erlend E. Aasland2023-05-073-50/+29
|
* gh-101819: Adapt _io.PyWindowsConsoleIO_Type to heap type (#104197)Erlend E. Aasland2023-05-073-69/+51
|
* gh-101819: Port _io.PyIncrementalNewlineDecoder_Type to heap type (#104249)Erlend E. Aasland2023-05-073-47/+42
|
* gh-101819: Remove unused 'locale_module' from _io state (#104246)Erlend E. Aasland2023-05-062-5/+0
| | | | The locale module reference was introduced by 932ff8368 in 2013, and rendered unused by 710e82630 (gh-23050) in 2020.
* gh-101819: Prepare to modernize the _io extension (#104178)Victor Stinner2023-05-059-37/+92
| | | | | | | | | | | | | | | | | | | | | * Add references to static types to _PyIO_State: * PyBufferedIOBase_Type * PyBytesIOBuffer_Type * PyIncrementalNewlineDecoder_Type * PyRawIOBase_Type * PyTextIOBase_Type * Add the defining class to methods: * _io.BytesIO.getbuffer() * _io.FileIO.close() * Add get_io_state_by_cls() function. * Add state parameter to _textiowrapper_decode() * _io_TextIOWrapper___init__() now sets self->state before calling _textiowrapper_set_decoder(). Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-94673: Properly Initialize and Finalize Static Builtin Types for Each ↵Eric Snow2023-05-021-6/+2
| | | | | Interpreter (gh-104072) Until now, we haven't been initializing nor finalizing the per-interpreter state properly.
* gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)Eric Snow2023-04-271-6/+4
| | | There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.
* gh-103617: Fix compiler warning in _iomodule.c (#103618)Erlend E. Aasland2023-04-191-2/+3
|
* gh-94673: Isolate the _io module to Each Interpreter (gh-102663)Eric Snow2023-03-211-8/+32
| | | | | Aside from sys and builtins, _io is the only core builtin module that hasn't been ported to multi-phase init. We may do so later (e.g. gh-101948), but in the meantime we must at least take care of the module's static types properly. (This came up while working on gh-101660.) https://github.com/python/cpython/issues/94673
* gh-102255: Improve build support for Windows API partitions (GH-102256)Max Bachmann2023-03-095-29/+33
| | | | | Add `MS_WINDOWS_DESKTOP`, `MS_WINDOWS_APPS`, `MS_WINDOWS_SYSTEM` and `MS_WINDOWS_GAMES` preprocessor definitions to allow switching off functionality missing from particular API partitions ("partitions" are used in Windows to identify overlapping subsets of APIs). CPython only officially supports `MS_WINDOWS_DESKTOP` and `MS_WINDOWS_SYSTEM` (APPS is included by normal desktop builds, but APPS without DESKTOP is not covered). Other configurations are a convenience for people building their own runtimes. `MS_WINDOWS_GAMES` is for the Xbox subset of the Windows API, which is also available on client OS, but is restricted compared to `MS_WINDOWS_DESKTOP`. These restrictions may change over time, as they relate to the build headers rather than the OS support, and so we assume that Xbox builds will use the latest available version of the GDK.
* gh-102507 Remove invisible pagebreak characters (#102531)JosephSBoyle2023-03-081-3/+0
| | | Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-246-71/+77
| | | | (in Modules/) (#102196)
* gh-101819: Adapt _io types to heap types, batch 1 (GH-101949)Erlend E. Aasland2023-02-208-469/+373
| | | | | Adapt StringIO, TextIOWrapper, FileIO, Buffered*, and BytesIO types. Automerge-Triggered-By: GH:erlend-aasland
* gh-101819: Remove _PyWindowsConsoleIO_Type from the Windows DLL (GH-101904)Erlend E. Aasland2023-02-152-7/+1
| | | Automerge-Triggered-By: GH:erlend-aasland
* gh-101819: Remove _testcapi dependencies on specific _io symbols (#101918)Erlend E. Aasland2023-02-151-10/+2
|
* GH-101228: Fix typo in docstring for read method of `_io.TextIOWrapper` ↵Partha P. Mukherjee2023-02-091-3/+3
| | | | class (#101227)
* gh-101409: Improve generated clinic code for self type checks (#101411)Erlend E. Aasland2023-01-311-3/+4
|
* gh-101469: Optimise get_io_state() by using _PyModule_GetState() (GH-101470)Erlend E. Aasland2023-01-311-1/+2
| | | Automerge-Triggered-By: GH:erlend-aasland
* gh-82052: Don't send partial UTF-8 sequences to the Windows API (GH-101103)Paul Moore2023-01-171-1/+16
| | | Don't send partial UTF-8 sequences to the Windows API
* gh-81057: Move More Globals to _PyRuntimeState (gh-100092)Eric Snow2022-12-071-12/+12
| | | https://github.com/python/cpython/issues/81057
* bpo-15999: Accept arbitrary values for boolean parameters. (#15609)Serhiy Storchaka2022-12-038-37/+36
| | | builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.