diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2019-09-10 12:56:14 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-09-10 12:56:14 (GMT) |
commit | 12c122ae958a55c9874ed4c7d7805ceb084411d7 (patch) | |
tree | 5e5dad44e8cd210e1f8d8348ed5be9695aee4d27 /Lib/asyncio/streams.py | |
parent | 9a94093189417adddd6b59d6c80cc5544630c8aa (diff) | |
download | cpython-12c122ae958a55c9874ed4c7d7805ceb084411d7.zip cpython-12c122ae958a55c9874ed4c7d7805ceb084411d7.tar.gz cpython-12c122ae958a55c9874ed4c7d7805ceb084411d7.tar.bz2 |
bpo-38066: Hide internal Stream methods (GH-15762)
feed_eof(), feed_data(), set_exception(), and set_transport() are prefixed with underscore now.
https://bugs.python.org/issue38066
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r-- | Lib/asyncio/streams.py | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index 33b2fa5..4943e8e 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -1133,9 +1133,9 @@ class _BaseStreamProtocol(FlowControlMixin, protocols.Protocol): stream = self._stream if stream is not None: if exc is None: - stream.feed_eof() + stream._feed_eof() else: - stream.set_exception(exc) + stream._set_exception(exc) if not self._closed.done(): if exc is None: self._closed.set_result(None) @@ -1147,12 +1147,12 @@ class _BaseStreamProtocol(FlowControlMixin, protocols.Protocol): def data_received(self, data): stream = self._stream if stream is not None: - stream.feed_data(data) + stream._feed_data(data) def eof_received(self): stream = self._stream if stream is not None: - stream.feed_eof() + stream._feed_eof() if self._over_ssl: # Prevent a warning in SSLProtocol.eof_received: # "returning true from eof_received() @@ -1219,7 +1219,7 @@ class _StreamProtocol(_BaseStreamProtocol): stream = self._stream if stream is None: return - stream.set_transport(transport) + stream._set_transport(transport) stream._protocol = self def connection_lost(self, exc): @@ -1351,6 +1351,11 @@ class Stream: @property def transport(self): + warnings.warn("Stream.transport attribute is deprecated " + "since Python 3.8 and is scheduled for removal in 3.10; " + "it is an internal API", + DeprecationWarning, + stacklevel=2) return self._transport def write(self, data): @@ -1366,7 +1371,7 @@ class Stream: def _fast_drain(self): # The helper tries to use fast-path to return already existing # complete future object if underlying transport is not paused - #and actual waiting for writing resume is not needed + # and actual waiting for writing resume is not needed exc = self.exception() if exc is not None: fut = self._loop.create_future() @@ -1450,6 +1455,14 @@ class Stream: return self._exception def set_exception(self, exc): + warnings.warn("Stream.set_exception() is deprecated " + "since Python 3.8 and is scheduled for removal in 3.10; " + "it is an internal API", + DeprecationWarning, + stacklevel=2) + self._set_exception(exc) + + def _set_exception(self, exc): self._exception = exc waiter = self._waiter @@ -1467,6 +1480,14 @@ class Stream: waiter.set_result(None) def set_transport(self, transport): + warnings.warn("Stream.set_transport() is deprecated " + "since Python 3.8 and is scheduled for removal in 3.10; " + "it is an internal API", + DeprecationWarning, + stacklevel=2) + self._set_transport(transport) + + def _set_transport(self, transport): if transport is self._transport: return assert self._transport is None, 'Transport already set' @@ -1478,6 +1499,14 @@ class Stream: self._transport.resume_reading() def feed_eof(self): + warnings.warn("Stream.feed_eof() is deprecated " + "since Python 3.8 and is scheduled for removal in 3.10; " + "it is an internal API", + DeprecationWarning, + stacklevel=2) + self._feed_eof() + + def _feed_eof(self): self._eof = True self._wakeup_waiter() @@ -1486,6 +1515,14 @@ class Stream: return self._eof and not self._buffer def feed_data(self, data): + warnings.warn("Stream.feed_data() is deprecated " + "since Python 3.8 and is scheduled for removal in 3.10; " + "it is an internal API", + DeprecationWarning, + stacklevel=2) + self._feed_data(data) + + def _feed_data(self, data): _ensure_can_read(self._mode) assert not self._eof, 'feed_data after feed_eof' |