Skip to content

Commit 0e45786

Browse files
gh-111356: io: Add missing documented objects to io.__all__ (GH-111370)
Add DEFAULT_BUFFER_SIZE, text_encoding, and IncrementalNewlineDecoder. (cherry picked from commit baeb771) Co-authored-by: Nicolas Tessore <[email protected]>
1 parent 226f4bc commit 0e45786

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Lib/io.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"FileIO", "BytesIO", "StringIO", "BufferedIOBase",
4646
"BufferedReader", "BufferedWriter", "BufferedRWPair",
4747
"BufferedRandom", "TextIOBase", "TextIOWrapper",
48-
"UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]
48+
"UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END",
49+
"DEFAULT_BUFFER_SIZE", "text_encoding", "IncrementalNewlineDecoder"]
4950

5051

5152
import _io

Lib/test/test_io.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -3949,19 +3949,18 @@ class PyIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest):
39493949

39503950
class MiscIOTest(unittest.TestCase):
39513951

3952+
# for test__all__, actual values are set in subclasses
3953+
name_of_module = None
3954+
extra_exported = ()
3955+
not_exported = ()
3956+
39523957
def tearDown(self):
39533958
os_helper.unlink(os_helper.TESTFN)
39543959

39553960
def test___all__(self):
3956-
for name in self.io.__all__:
3957-
obj = getattr(self.io, name, None)
3958-
self.assertIsNotNone(obj, name)
3959-
if name in ("open", "open_code"):
3960-
continue
3961-
elif "error" in name.lower() or name == "UnsupportedOperation":
3962-
self.assertTrue(issubclass(obj, Exception), name)
3963-
elif not name.startswith("SEEK_"):
3964-
self.assertTrue(issubclass(obj, self.IOBase))
3961+
support.check__all__(self, self.io, self.name_of_module,
3962+
extra=self.extra_exported,
3963+
not_exported=self.not_exported)
39653964

39663965
def test_attributes(self):
39673966
f = self.open(os_helper.TESTFN, "wb", buffering=0)
@@ -4328,6 +4327,8 @@ def test_openwrapper(self):
43284327

43294328
class CMiscIOTest(MiscIOTest):
43304329
io = io
4330+
name_of_module = "io", "_io"
4331+
extra_exported = "BlockingIOError",
43314332

43324333
def test_readinto_buffer_overflow(self):
43334334
# Issue #18025
@@ -4392,6 +4393,9 @@ def test_daemon_threads_shutdown_stderr_deadlock(self):
43924393

43934394
class PyMiscIOTest(MiscIOTest):
43944395
io = pyio
4396+
name_of_module = "_pyio", "io"
4397+
extra_exported = "BlockingIOError", "open_code",
4398+
not_exported = "valid_seek_flags",
43954399

43964400

43974401
@unittest.skipIf(os.name == 'nt', 'POSIX signals required for this test.')
@@ -4679,7 +4683,7 @@ def load_tests(loader, tests, pattern):
46794683
mocks = (MockRawIO, MisbehavedRawIO, MockFileIO, CloseFailureIO,
46804684
MockNonBlockWriterIO, MockUnseekableIO, MockRawIOWithoutRead,
46814685
SlowFlushRawIO)
4682-
all_members = io.__all__ + ["IncrementalNewlineDecoder"]
4686+
all_members = io.__all__
46834687
c_io_ns = {name : getattr(io, name) for name in all_members}
46844688
py_io_ns = {name : getattr(pyio, name) for name in all_members}
46854689
globs = globals()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added :func:`io.text_encoding()`, :data:`io.DEFAULT_BUFFER_SIZE`, and :class:`io.IncrementalNewlineDecoder` to ``io.__all__``.

0 commit comments

Comments
 (0)