summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43260: io: Prevent large data remains in textio buffer. (GH-24592)Inada Naoki2021-02-221-0/+27
| | | | | | | | | 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. (cherry picked from commit 01806d5beba3d208bb56adba6829097d803bf54f)
* bpo-41401: Fix test_fspath_support in test_io. (GH-21640) (GH-22133) (GH-22135)Victor Stinner2020-09-071-1/+1
| | | | | | | | The error is exposed on non-UTF-8 locales. (cherry picked from commit 67987acd5dc9776f55f4e139e2b3d9e7a6434d9f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit c73ee5acc96b4bbd6885156883b224b8cc3e470c)
* closes bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18295)Miss Islington (bot)2020-02-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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)) GH-GH-GH- 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> (cherry picked from commit cb1c0746f277052e45a60d6c436a765e34722821) Co-authored-by: Philipp Gesang <phg@phi-gamma.net>
* [3.8] closes bpo-27805: Ignore ESPIPE in initializing seek of append-mode ↵Benjamin Peterson2019-11-121-0/+11
| | | | | | files. (GH-17136) 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.. (cherry picked from commit 74fa9f723f700a342e582b5ad4b51a2c4801cd1c)
* bpo-37261: Document sys.unraisablehook corner cases (GH-14059)Miss Islington (bot)2019-06-141-1/+5
| | | | | | | | | | | | | | Document reference cycle and resurrected objects issues in sys.unraisablehook() and threading.excepthook() documentation. Fix test.support.catch_unraisable_exception(): __exit__() no longer ignores unraisable exceptions. Fix test_io test_writer_close_error_on_close(): use a second catch_unraisable_exception() to catch the BufferedWriter unraisable exception. (cherry picked from commit 212646cae6b7c4ddc8d98c8b9b6d39a5f259e864) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-37223: test_io: silence destructor errors (GH-14031)Victor Stinner2019-06-121-0/+15
| | | | | | | | | | | | | | | | | | | | | | | * bpo-18748: Fix _pyio.IOBase destructor (closed case) (GH-13952) _pyio.IOBase destructor now does nothing if getting the closed attribute fails to better mimick _io.IOBase finalizer. (cherry picked from commit 4f6f7c5a611905fb6b81671547f268c226bc646a) * bpo-37223: test_io: silence destructor errors (GH-13954) Implement also MockNonBlockWriterIO.seek() method. (cherry picked from commit b589cef9c4dada2fb84ce0fae5040ecf16d9d5ef) * bpo-37223, test_io: silence last 'Exception ignored in:' (GH-14029) Use catch_unraisable_exception() to ignore 'Exception ignored in:' error when the internal BufferedWriter of the BufferedRWPair is destroyed. The C implementation doesn't give access to the internal BufferedWriter, so just ignore the warning instead. (cherry picked from commit 913fa1c8245d1cde6edb4254f4fb965cc91786ef)
* bpo-36829: Document test.support.catch_unraisable_exception() (GH-13554)Victor Stinner2019-05-241-14/+6
| | | | catch_unraisable_exception() now also removes its 'unraisable' attribute at the context manager exit.
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-1/+1
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-18748: _pyio.IOBase emits unraisable exception (GH-13512)Victor Stinner2019-05-231-37/+27
| | | | | | | | In development (-X dev) mode and in a debug build, IOBase finalizer of the _pyio module now logs the exception if the close() method fails. The exception is ignored silently by default in release build. test_io: test_error_through_destructor() now uses support.catch_unraisable_exception() rather than capturing stderr.
* bpo-36929: Modify io/re tests to allow for missing mod name (#13392)Max Bernstein2019-05-211-17/+17
| | | | | | | | | | | | | | | | | | * bpo-36929: Modify io/re tests to allow for missing mod name For a vanishingly small number of internal types, CPython sets the tp_name slot to mod_name.type_name, either in the PyTypeObject or the PyType_Spec. There are a few minor places where this surfaces: * Custom repr functions for those types (some of which ignore the tp_name in favor of using a string literal, such as _io.TextIOWrapper) * Pickling error messages The test suite only tests the former. This commit modifies the test suite to allow Python implementations to omit the module prefix. https://bugs.python.org/issue36929
* bpo-18748: test_io: silence destructor errors (GH-12805)Victor Stinner2019-04-121-0/+29
|
* bpo-18748: io.IOBase destructor now logs close() errors in dev mode (GH-12786)Victor Stinner2019-04-121-6/+25
| | | | | In development mode (-X dev) and in debug build, the io.IOBase destructor now logs close() exceptions. These exceptions are silent by default in release mode.
* bpo-35214: Skip test_io tests that'd cause a huge malloc under msan (#11385)Gregory P. Smith2018-12-311-0/+14
| | | | | | | | | | * skip test_constructor under msan. * fix the others as well. * reuse existing related news entry. * typo fix
* bpo-31731: Fix test_io.check_interrupted_write() (GH-11225)Victor Stinner2018-12-181-3/+9
| | | | | | | Fix a race condition in check_interrupted_write() of test_io: create directly the thread with SIGALRM signal blocked, rather than blocking the signal later from the thread. Previously, it was possible that the thread gets the signal before the signal is blocked.
* bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. ↵Zackery Spytz2018-12-171-0/+5
| | | | (GH-11175)
* bpo-33578: Add getstate/setstate for CJK codec (GH-6984)Christopher Thorne2018-11-011-0/+28
| | | | | | | | This implements getstate and setstate for the cjkcodecs multibyte incremental encoders/decoders, primarily to fix issues with seek/tell. The encoder getstate/setstate is slightly tricky as the "state" is pending bytes + MultibyteCodec_State but only an integer can be returned. The approach I've taken is to encode this data into a long, similar to how .tell() encodes a "cookie_type" as a long. https://bugs.python.org/issue33578
* bpo-35062: Fix parsing _io.IncrementalNewlineDecoder's *translate* argument. ↵Xiang Zhang2018-10-311-0/+10
| | | | | | (GH-10217) _io.IncrementalNewlineDecoder's initializer possibly assigns out-of-range value to the bitwise struct field.
* bpo-32236: open() emits RuntimeWarning if buffering=1 for binary mode (GH-4842)Alexey Izbyshev2018-10-201-1/+1
| | | | | | | | | If buffering=1 is specified for open() in binary mode, it is silently treated as buffering=-1 (i.e., the default buffer size). Coupled with the fact that line buffering is always supported in Python 2, such behavior caused several issues (e.g., bpo-10344, bpo-21332). Warn that line buffering is not supported if open() is called with binary mode and buffering=1.
* bpo-34068: _io__IOBase_close_impl could call _PyObject_SetAttrId with an ↵Zackery Spytz2018-07-171-0/+10
| | | | exception set (GH-8282)
* bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)Zackery Spytz2018-06-291-0/+11
|
* Revert "bpo-33671: Add support.MS_WINDOWS and support.MACOS (GH-7800)" (GH-7919)Victor Stinner2018-06-261-1/+1
| | | This reverts commit 8fbbdf0c3107c3052659e166f73990b466eacbb0.
* bpo-33671: Add support.MS_WINDOWS and support.MACOS (GH-7800)Victor Stinner2018-06-221-1/+1
| | | | | | | | * Add support.MS_WINDOWS: True if Python is running on Microsoft Windows. * Add support.MACOS: True if Python is running on Apple macOS. * Replace support.is_android with support.ANDROID * Replace support.is_jython with support.JYTHON * Cleanup code to initialize unix_shell
* bpo-33760: Fix file leaks in test_io. (GH-7361)Serhiy Storchaka2018-06-041-0/+4
|
* bpo-32964: Reuse a testing implementation of the path protocol in tests. (#5930)Serhiy Storchaka2018-03-021-11/+14
|
* bpo-32228: Reset raw_pos after unwinding the raw stream (#4858)Nitish Chandra2018-01-281-0/+17
| | | Ensure that ``truncate()`` preserves the file position (as reported by ``tell()``) after writes longer than the buffer size.
* bpo-32593: Drop FreeBSD 9 and older support (#5232)Victor Stinner2018-01-221-2/+0
| | | Drop support of FreeBSD 9 and older.
* bpo-15216: io: TextIOWrapper.reconfigure() accepts encoding, errors and ↵INADA Naoki2017-12-211-0/+117
| | | | newline (GH-2343)
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-141-1/+1
| | | | | | | | * Fix multiple typos in code comments * Add spacing in comments (test_logging.py, test_math.py) * Fix spaces at the beginning of comments in test_logging.py
* bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)Victor Stinner2017-12-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | * Add -X utf8 command line option, PYTHONUTF8 environment variable and a new sys.flags.utf8_mode flag. * If the LC_CTYPE locale is "C" at startup: enable automatically the UTF-8 mode. * Add _winapi.GetACP(). encodings._alias_mbcs() now calls _winapi.GetACP() to get the ANSI code page * locale.getpreferredencoding() now returns 'UTF-8' in the UTF-8 mode. As a side effect, open() now uses the UTF-8 encoding by default in this mode. * Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding in the UTF-8 Mode. * Update subprocess._args_from_interpreter_flags() to handle -X utf8 * Skip some tests relying on the current locale if the UTF-8 mode is enabled. * Add test_utf8mode.py. * _Py_DecodeUTF8_surrogateescape() gets a new optional parameter to return also the length (number of wide characters). * pymain_get_global_config() and pymain_set_global_config() now always copy flag values, rather than only copying if the new value is greater than the old value.
* bpo-22671: Clarify and test default read method implementations (#4568)Sanyam Khurana2017-12-111-2/+51
| | | Original patch written by Martin Panter, enhanced by Sanyam Khurana.
* bpo-31976: Fix race condition when flushing a file is slow. (#4331)benfogle2017-11-101-1/+30
|
* Replace KB unit with KiB (#4293)Victor Stinner2017-11-081-5/+5
| | | | | | | | | | | kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte") means 1024 bytes. KB was misused: replace kB or KB with KiB when appropriate. Same change for MB and GB which become MiB and GiB. Change the output of Tools/iobench/iobench.py. Round also the size of the documentation from 5.5 MB to 5 MiB.
* bpo-31479: Always reset the signal alarm in tests (#3588)Victor Stinner2017-09-191-0/+3
| | | | | | | | | | | | | * bpo-31479: Always reset the signal alarm in tests Use "try: ... finally: signal.signal(0)" pattern to make sure that tests don't "leak" a pending fatal signal alarm. * Move two more alarm() calls into the try block Fix also typo: replace signal.signal(0) with signal.alarm(0) * Move another signal.alarm() into the try block
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-12/+1
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-31243: Fixed PyArg_ParseTuple failure checks. (#3171)Oren Milman2017-08-291-0/+20
|
* bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (#3201)Oren Milman2017-08-251-0/+8
|
* bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal ↵Oren Milman2017-08-201-0/+1
| | | | tuples. (#3119)
* Fix bpo-30526: Add TextIOWrapper.reconfigure() and a ↵Antoine Pitrou2017-06-031-0/+51
| | | | | | | | | | TextIOWrapper.write_through attribute (#1922) * Fix bpo-30526: Add TextIOWrapper.reconfigure() * Apply Nick's improved wording * Update Misc/NEWS
* bpo-30107: don't dump core on expected test_io crash (#1235)Victor Stinner2017-04-211-0/+5
| | | | | | | | | | | | | | test_io has two unit tests which trigger a deadlock: * test_daemon_threads_shutdown_stdout_deadlock() * test_daemon_threads_shutdown_stderr_deadlock() These tests call Py_FatalError() if the expected bug is triggered which calls abort(). Use test.support.SuppressCrashReport to prevent the creation on a core dump, to fix the warning: Warning -- files was modified by test_io Before: [] After: ['python.core']
* bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096)Serhiy Storchaka2017-04-191-0/+16
| | | | | | raised an error. Replace them with using concrete types API that never fails if appropriate.
* bpo-30068: add missing iter(self) in _io._IOBase.readlines when hint is ↵Xiang Zhang2017-04-151-0/+1
| | | | present (#1130)
* bpo-25455: Fixed crashes in repr of recursive buffered file-like objects. (#514)Serhiy Storchaka2017-03-191-0/+20
|
* Issue #26926: Merge 3.6Xavier de Gaye2016-11-171-1/+4
|\
| * Issue #26926: Skip some test_io tests on platforms without large file supportXavier de Gaye2016-11-171-1/+4
| |
* | Issue #23214: Implement optional BufferedReader, BytesIO read1() argumentMartin Panter2016-10-201-2/+14
|/
* Use sequence repetition instead of bytes constructor with integer argument.Serhiy Storchaka2016-09-111-1/+1
|
* Fixes expected error when getting encoding while shutting down.Steve Dower2016-09-091-1/+1
|
* Fix expected error message in PyTextIOWrapperTestSteve Dower2016-09-081-1/+1
|
* Issue #27959: Prevent ImportError from escaping codec search functionSteve Dower2016-09-071-2/+1
|
* new and exciting shutdown error on windowsBenjamin Peterson2016-09-071-1/+2
|