Skip to content

Commit 17e0e75

Browse files
authored
Merge pull request #2323 from RustPython/coolreader18/buffer-io
Fully implement buffered IO
2 parents 0b9beeb + 9433126 commit 17e0e75

33 files changed

Lines changed: 10002 additions & 891 deletions

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
test_argparse test_json test_bytes test_long test_pwd test_bool test_cgi test_complex
124124
test_exception_hierarchy test_glob test_iter test_list test_os test_pathlib
125125
test_py_compile test_set test_shutil test_sys test_unicode test_unittest test_venv
126-
test_zipimport test_importlib
126+
test_zipimport test_importlib test_io
127127
env:
128128
RUSTPYTHONPATH: ${{ github.workspace }}/Lib
129129
if: runner.os == 'Windows'

Lib/_pyio.py

Lines changed: 2685 additions & 0 deletions
Large diffs are not rendered by default.

Lib/io.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"Amaury Forgeot d'Arc <amauryfa@gmail.com>, "
4242
"Benjamin Peterson <benjamin@python.org>")
4343

44-
__all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",
45-
"BytesIO", "StringIO", "BufferedIOBase",
44+
__all__ = ["BlockingIOError", "open", "open_code", "IOBase", "RawIOBase",
45+
"FileIO", "BytesIO", "StringIO", "BufferedIOBase",
4646
"BufferedReader", "BufferedWriter", "BufferedRWPair",
4747
"BufferedRandom", "TextIOBase", "TextIOWrapper",
4848
"UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]
@@ -51,12 +51,17 @@
5151
import _io
5252
import abc
5353

54-
from _io import *
54+
from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
55+
open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
56+
BufferedWriter, BufferedRWPair, BufferedRandom,
57+
# XXX RUSTPYTHON TODO: IncrementalNewlineDecoder
58+
# IncrementalNewlineDecoder, TextIOWrapper)
59+
TextIOWrapper)
5560

5661
OpenWrapper = _io.open # for compatibility with _pyio
5762

5863
# Pretend this exception was created here.
59-
#UnsupportedOperation.__module__ = "io"
64+
UnsupportedOperation.__module__ = "io"
6065

6166
# for seek()
6267
SEEK_SET = 0
@@ -83,8 +88,8 @@ class TextIOBase(_io._TextIOBase, IOBase):
8388
except NameError:
8489
pass
8590

86-
for klass in (BytesIO, BufferedReader, BufferedWriter):#, BufferedRandom,
87-
#BufferedRWPair):
91+
for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom,
92+
BufferedRWPair):
8893
BufferedIOBase.register(klass)
8994

9095
for klass in (StringIO, TextIOWrapper):

Lib/test/test_cgi.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ def test_log(self):
203203
self.addCleanup(cgi.closelog)
204204
cgi.log("Testing log 4")
205205

206-
# TODO RUSTPYTHON
207-
@unittest.expectedFailure
208206
def test_fieldstorage_readline(self):
209207
# FieldStorage uses readline, which has the capacity to read all
210208
# contents of the input file into memory; we use readline's size argument
@@ -294,8 +292,6 @@ def test_fieldstorage_multipart_non_ascii(self):
294292
got = getattr(fs.list[x], k)
295293
self.assertEqual(got, exp)
296294

297-
# TODO RUSTPYTHON
298-
@unittest.expectedFailure
299295
def test_fieldstorage_multipart_maxline(self):
300296
# Issue #18167
301297
maxline = 1 << 16

0 commit comments

Comments
 (0)