Commit 97d15b1e authored by Andrew Svetlov's avatar Andrew Svetlov Committed by GitHub

Replace deprecation warning with RuntimeError (GH-14397)

parent 667eaffb
...@@ -1293,10 +1293,8 @@ class Stream: ...@@ -1293,10 +1293,8 @@ class Stream:
is_server_side=False, is_server_side=False,
_asyncio_internal=False): _asyncio_internal=False):
if not _asyncio_internal: if not _asyncio_internal:
warnings.warn(f"{self.__class__} should be instaniated " raise RuntimeError(f"{self.__class__} should be instantiated "
"by asyncio internals only, " "by asyncio internals only")
"please avoid its creation from user code",
DeprecationWarning)
self._mode = mode self._mode = mode
self._transport = transport self._transport = transport
self._protocol = protocol self._protocol = protocol
......
...@@ -1779,6 +1779,12 @@ os.close(fd) ...@@ -1779,6 +1779,12 @@ os.close(fd)
self.loop.run_until_complete(test()) self.loop.run_until_complete(test())
def test_stream_ctor_forbidden(self):
with self.assertRaisesRegex(RuntimeError,
"should be instantiated "
"by asyncio internals only"):
asyncio.Stream(asyncio.StreamMode.READWRITE)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment