8000 [3.8] bpo-36889: Replace deprecation warning with RuntimeError (GH-14397) by miss-islington · Pull Request #14422 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.8] bpo-36889: Replace deprecation warning with RuntimeError (GH-14397) #14422

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
Jun 27, 2019
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
Replace deprecation warning with RuntimeError (GH-14397)
(cherry picked from commit 97d15b1)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
  • Loading branch information
asvetlov authored and miss-islington committed Jun 27, 2019
commit 9b332df3cc9e71d0aab727c8c69f87c8c4a5736e
6 changes: 2 additions & 4 deletions Lib/asyncio/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,10 +1293,8 @@ def __init__(self, mode, *,
is_server_side=False,
_asyncio_internal=False):
if not _asyncio_internal:
warnings.warn(f"{self.__class__} should be instaniated "
"by asyncio internals only, "
"please avoid its creation from user code",
DeprecationWarning)
raise RuntimeError(f"{self.__class__} should be instantiated "
"by asyncio internals only")
self._mode = mode
self._transport = transport
self._protocol = protocol
Expand Down
8063 6 changes: 6 additions & 0 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,12 @@ async def 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__':
unittest.main()
0