summaryrefslogtreecommitdiffstats
path: root/Doc/library/telnetlib.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2015-11-28 17:24:52 (GMT)
committerR David Murray <rdmurray@bitdance.com>2015-11-28 17:24:52 (GMT)
commit4f09806e662928c5524ab5d792d73297c50494b3 (patch)
tree74a8b786e7c43de01493bc1b84ad1e38367219c4 /Doc/library/telnetlib.rst
parent37f54219543f9cb6ebf6a94cfe1eb402bc9b5580 (diff)
downloadcpython-4f09806e662928c5524ab5d792d73297c50494b3.zip
cpython-4f09806e662928c5524ab5d792d73297c50494b3.tar.gz
cpython-4f09806e662928c5524ab5d792d73297c50494b3.tar.bz2
#25485: Add context manager support to Telnet class.
Patch by Stéphane Wirtel.
Diffstat (limited to 'Doc/library/telnetlib.rst')
-rw-r--r--Doc/library/telnetlib.rst11
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/telnetlib.rst b/Doc/library/telnetlib.rst
index 4040f72..ce406ca 100644
--- a/Doc/library/telnetlib.rst
+++ b/Doc/library/telnetlib.rst
@@ -43,6 +43,17 @@ Character), EL (Erase Line), GA (Go Ahead), SB (Subnegotiation Begin).
:exc:`EOFError` when the end of the connection is read, because they can return
an empty string for other reasons. See the individual descriptions below.
+ A :class:`Telnet` object is a context manager and can be used in a
+ :keyword:`with` statement. When the :keyword:`with` block ends, the
+ :meth:`close` method is called::
+
+ >>> from telnetlib import Telnet
+ >>> with Telnet('localhost', 23) as tn:
+ ... tn.interact()
+ ...
+
+ .. versionchanged:: 3.6 Context manager support added
+
.. seealso::