Skip to content

Commit baeb771

Browse files
authored
pythongh-111356: io: Add missing documented objects to io.__all__ (python#111370)
Add DEFAULT_BUFFER_SIZE, text_encoding, and IncrementalNewlineDecoder.
1 parent 289af86 commit baeb771

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Lib/io.py

Lines changed: 2 additions & 1 deletion
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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,19 +4042,18 @@ class PyIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest):
40424042

40434043
class MiscIOTest(unittest.TestCase):
40444044

4045+
# for test__all__, actual values are set in subclasses
4046+
name_of_module = None
4047+
extra_exported = ()
4048+
not_exported = ()
4049+
40454050
def tearDown(self):
40464051
os_helper.unlink(os_helper.TESTFN)
40474052

40484053
def test___all__(self):
4049-
for name in self.io.__all__:
4050-
obj = getattr(self.io, name, None)
4051-
self.assertIsNotNone(obj, name)
4052-
if name in ("open", "open_code"):
4053-
continue
4054-
elif "error" in name.lower() or name == "UnsupportedOperation":
4055-
self.assertTrue(issubclass(obj, Exception), name)
4056-
elif not name.startswith("SEEK_"):
4057-
self.assertTrue(issubclass(obj, self.IOBase))
4054+
support.check__all__(self, self.io, self.name_of_module,
4055+
extra=self.extra_exported,
4056+
not_exported=self.not_exported)
40584057

40594058
def test_attributes(self):
40604059
f = self.open(os_helper.TESTFN, "wb", buffering=0)
@@ -4416,6 +4415,8 @@ def test_text_encoding(self):
44164415

44174416
class CMiscIOTest(MiscIOTest):
44184417
io = io
4418+
name_of_module = "io", "_io"
4419+
extra_exported = "BlockingIOError",
44194420

44204421
def test_readinto_buffer_overflow(self):
44214422
# Issue #18025
@@ -4480,6 +4481,9 @@ def test_daemon_threads_shutdown_stderr_deadlock(self):
44804481

44814482
class PyMiscIOTest(MiscIOTest):
44824483
io = pyio
4484+
name_of_module = "_pyio", "io"
4485+
extra_exported = "BlockingIOError", "open_code",
4486+
not_exported = "valid_seek_flags",
44834487

44844488

44854489
@unittest.skipIf(os.name == 'nt', 'POSIX signals required for this test.')
@@ -4767,7 +4771,7 @@ def load_tests(loader, tests, pattern):
47674771
mocks = (MockRawIO, MisbehavedRawIO, MockFileIO, CloseFailureIO,
47684772
MockNonBlockWriterIO, MockUnseekableIO, MockRawIOWithoutRead,
47694773
SlowFlushRawIO)
4770-
all_members = io.__all__ + ["IncrementalNewlineDecoder"]
4774+
all_members = io.__all__
47714775
c_io_ns = {name : getattr(io, name) for name in all_members}
47724776
py_io_ns = {name : getattr(pyio, name) for name in all_members}
47734777
globs = globals()
Lines changed: 1 addition & 0 deletions
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)