Skip to content

Commit 95141aa

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 4018209 commit 95141aa

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
@@ -4052,19 +4052,18 @@ class PyIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest):
40524052

40534053
class MiscIOTest(unittest.TestCase):
40544054

4055+
# for test__all__, actual values are set in subclasses
4056+
name_of_module = None
4057+
extra_exported = ()
4058+
not_exported = ()
4059+
40554060
def tearDown(self):
40564061
os_helper.unlink(os_helper.TESTFN)
40574062

40584063
def test___all__(self):
4059-
for name in self.io.__all__:
4060-
obj = getattr(self.io, name, None)
4061-
self.assertIsNotNone(obj, name)
4062-
if name in ("open", "open_code"):
4063-
continue
4064-
elif "error" in name.lower() or name == "UnsupportedOperation":
4065-
self.assertTrue(issubclass(obj, Exception), name)
4066-
elif not name.startswith("SEEK_"):
4067-
self.assertTrue(issubclass(obj, self.IOBase))
4064+
support.check__all__(self, self.io, self.name_of_module,
4065+
extra=self.extra_exported,
4066+
not_exported=self.not_exported)
40684067

40694068
def test_attributes(self):
40704069
f = self.open(os_helper.TESTFN, "wb", buffering=0)
@@ -4426,6 +4425,8 @@ def test_text_encoding(self):
44264425

44274426
class CMiscIOTest(MiscIOTest):
44284427
io = io
4428+
name_of_module = "io", "_io"
4429+
extra_exported = "BlockingIOError",
44294430

44304431
def test_readinto_buffer_overflow(self):
44314432
# Issue #18025
@@ -4490,6 +4491,9 @@ def test_daemon_threads_shutdown_stderr_deadlock(self):
44904491

44914492
class PyMiscIOTest(MiscIOTest):
44924493
io = pyio
4494+
name_of_module = "_pyio", "io"
4495+
extra_exported = "BlockingIOError", "open_code",
4496+
not_exported = "valid_seek_flags",
44934497

44944498

44954499
@unittest.skipIf(os.name == 'nt', 'POSIX signals required for this test.')
@@ -4777,7 +4781,7 @@ def load_tests(loader, tests, pattern):
47774781
mocks = (MockRawIO, MisbehavedRawIO, MockFileIO, CloseFailureIO,
47784782
MockNonBlockWriterIO, MockUnseekableIO, MockRawIOWithoutRead,
47794783
SlowFlushRawIO)
4780-
all_members = io.__all__ + ["IncrementalNewlineDecoder"]
4784+
all_members = io.__all__
47814785
c_io_ns = {name : getattr(io, name) for name in all_members}
47824786
py_io_ns = {name : getattr(pyio, name) for name in all_members}
47834787
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)