Skip to content

Commit 23b4b69

Browse files
asvetlovmiss-islington
authored andcommitted
1 parent 6f6ff8a commit 23b4b69

13 files changed

+2065
-393
lines changed

Lib/asyncio/__init__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# flake8: noqa
44

55
import sys
6+
import warnings
67

78
# This relies on each of the submodules having an __all__ variable.
89
from .base_events import *
@@ -43,3 +44,40 @@
4344
else:
4445
from .unix_events import * # pragma: no cover
4546
__all__ += unix_events.__all__
47+
48+
49+
__all__ += ('StreamReader', 'StreamWriter', 'StreamReaderProtocol') # deprecated
50+
51+
52+
def __getattr__(name):
53+
global StreamReader, StreamWriter, StreamReaderProtocol
54+
if name == 'StreamReader':
55+
warnings.warn("StreamReader is deprecated since Python 3.8 "
56+
"in favor of Stream, and scheduled for removal "
57+
"in Python 3.10",
58+
DeprecationWarning,
59+
stacklevel=2)
60+
from .streams import StreamReader as sr
61+
StreamReader = sr
62+
return StreamReader
63+
if name == 'StreamWriter':
64+
warnings.warn("StreamWriter is deprecated since Python 3.8 "
65+
"in favor of Stream, and scheduled for removal "
66+
"in Python 3.10",
67+
DeprecationWarning,
68+
stacklevel=2)
69+
from .streams import StreamWriter as sw
70+
StreamWriter = sw
71+
return StreamWriter
72+
if name == 'StreamReaderProtocol':
73+
warnings.warn("Using asyncio internal class StreamReaderProtocol "
74+
"is deprecated since Python 3.8 "
75+
" and scheduled for removal "
76+
"in Python 3.10",
77+
DeprecationWarning,
78+
stacklevel=2)
79+
from .streams import StreamReaderProtocol as srp
80+
StreamReaderProtocol = srp
81+
return StreamReaderProtocol
82+
83+
raise AttributeError(f"module {__name__} has no attribute {name}")

0 commit comments

Comments
 (0)