summaryrefslogtreecommitdiff
path: root/Doc/faq/library.rst
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-04-12 13:52:49 +0300
committerBerker Peksag <berker.peksag@gmail.com>2015-04-12 13:52:49 +0300
commit9575e1891ff533318f6dd72ab6f6bd0f9a042014 (patch)
treeb9ebbcf4b0db1eb78f209b2b5ec26a623cfda1fc /Doc/faq/library.rst
parent8ad751e0241b7bfbdfacff017c47794b3b0a3211 (diff)
downloadcpython-git-9575e1891ff533318f6dd72ab6f6bd0f9a042014.tar.gz
Issue #12955: Change the urlopen() examples to use context managers where appropriate.
Patch by Martin Panter.
Diffstat (limited to 'Doc/faq/library.rst')
-rw-r--r--Doc/faq/library.rst3
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst
index d71a9b47fb..064728ff68 100644
--- a/Doc/faq/library.rst
+++ b/Doc/faq/library.rst
@@ -687,7 +687,8 @@ Yes. Here's a simple example that uses urllib.request::
### connect and send the server a path
req = urllib.request.urlopen('http://www.some-server.out-there'
'/cgi-bin/some-cgi-script', data=qs)
- msg, hdrs = req.read(), req.info()
+ with req:
+ msg, hdrs = req.read(), req.info()
Note that in general for percent-encoded POST operations, query strings must be
quoted using :func:`urllib.parse.urlencode`. For example, to send