Skip to content

[3.11] gh-111356: io: Add missing documented objects to io.__all__ (GH-111370) #111936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"FileIO", "BytesIO", "StringIO", "BufferedIOBase",
"BufferedReader", "BufferedWriter", "BufferedRWPair",
"BufferedRandom", "TextIOBase", "TextIOWrapper",
"UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]
"UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END",
"DEFAULT_BUFFER_SIZE", "text_encoding", "IncrementalNewlineDecoder"]


import _io
Expand Down
24 changes: 14 additions & 10 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3949,19 +3949,18 @@ class PyIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest):

class MiscIOTest(unittest.TestCase):

# for test__all__, actual values are set in subclasses
name_of_module = None
extra_exported = ()
not_exported = ()

def tearDown(self):
os_helper.unlink(os_helper.TESTFN)

def test___all__(self):
for name in self.io.__all__:
obj = getattr(self.io, name, None)
self.assertIsNotNone(obj, name)
if name in ("open", "open_code"):
continue
elif "error" in name.lower() or name == "UnsupportedOperation":
self.assertTrue(issubclass(obj, Exception), name)
elif not name.startswith("SEEK_"):
self.assertTrue(issubclass(obj, self.IOBase))
support.check__all__(self, self.io, self.name_of_module,
extra=self.extra_exported,
not_exported=self.not_exported)

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

class CMiscIOTest(MiscIOTest):
io = io
name_of_module = "io", "_io"
extra_exported = "BlockingIOError",

def test_readinto_buffer_overflow(self):
# Issue #18025
Expand Down Expand Up @@ -4392,6 +4393,9 @@ def test_daemon_threads_shutdown_stderr_deadlock(self):

class PyMiscIOTest(MiscIOTest):
io = pyio
name_of_module = "_pyio", "io"
extra_exported = "BlockingIOError", "open_code",
not_exported = "valid_seek_flags",


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