8000 Replace deprecation warning with RuntimeError (GH-14397) · python/cpython@4cbe7a3 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cbe7a3

Browse files
Replace deprecation warning with RuntimeError (GH-14397)
(cherry picked from commit 97d15b1) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
1 parent 7e9d706 commit 4cbe7a3

File tree

2 files changed

+8
-4
lines changed

2 8000 files changed

+8
-4
lines changed

Lib/asyncio/streams.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,10 +1293,8 @@ def __init__(self, mode, *,
12931293
is_server_side=False,
12941294
_asyncio_internal=False):
12951295
if not _asyncio_internal:
1296-
warnings.warn(f"{self.__class__} should be instaniated "
1297-
"by asyncio internals only, "
1298-
"please avoid its creation from user code",
1299-
DeprecationWarning)
1296+
raise RuntimeError(f"{self.__class__} should be instantiated "
1297+
"by asyncio internals only")
13001298
self._mode = mode
13011299
self._transport = transport
13021300
self._protocol = protocol

Lib/test/test_asyncio/test_streams.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,12 @@ async def test():
17791779

17801780
self.loop.run_until_complete(test())
17811781

1782+
def test_stream_ctor_forbidden(self):
1783+
with self.assertRaisesRegex(RuntimeError,
1784+
"should be instantiated "
1785+
"by asyncio internals only"):
1786+
asyncio.Stream(asyncio.StreamMode.READWRITE)
1787+
17821788

17831789
if __name__ == '__main__':
17841790
unittest.main()

0 commit comments

Comments
 (0)
0