diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2012-10-09 07:37:09 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2012-10-09 07:37:09 (GMT) |
commit | 1ed9847a5ae9758aada921222788c95c1aa78958 (patch) | |
tree | e22edfc745a741f0dc55424a2bc5ce033d4a99dc | |
parent | b5ca932be26a1762b9db78b29f2946fd9ae3c2d4 (diff) | |
download | cpython-1ed9847a5ae9758aada921222788c95c1aa78958.zip cpython-1ed9847a5ae9758aada921222788c95c1aa78958.tar.gz cpython-1ed9847a5ae9758aada921222788c95c1aa78958.tar.bz2 |
Fix Issue 15922: make howto/urllib2.rst doctests pass.
Patch by Chris Jerdonek. Address Ezio's review comment.
-rw-r--r-- | Doc/howto/urllib2.rst | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst index fade4a3..87f42ba 100644 --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -137,7 +137,7 @@ This is done as follows:: >>> data['location'] = 'Northampton' >>> data['language'] = 'Python' >>> url_values = urllib.parse.urlencode(data) - >>> print(url_values) + >>> print(url_values) # The order may differ from below. #doctest: +SKIP name=Somebody+Here&language=Python&location=Northampton >>> url = 'http://www.example.com/example.cgi' >>> full_url = url + '?' + url_values @@ -207,9 +207,9 @@ e.g. :: >>> req = urllib.request.Request('http://www.pretend_server.org') >>> try: urllib.request.urlopen(req) - >>> except urllib.error.URLError as e: - >>> print(e.reason) - >>> + ... except urllib.error.URLError as e: + ... print(e.reason) #doctest: +SKIP + ... (4, 'getaddrinfo failed') @@ -315,18 +315,17 @@ geturl, and info, methods as returned by the ``urllib.response`` module:: >>> req = urllib.request.Request('http://www.python.org/fish.html') >>> try: - >>> urllib.request.urlopen(req) - >>> except urllib.error.HTTPError as e: - >>> print(e.code) - >>> print(e.read()) - >>> + ... urllib.request.urlopen(req) + ... except urllib.error.HTTPError as e: + ... print(e.code) + ... print(e.read()) #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + ... 404 - <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> - <?xml-stylesheet href="./css/ht2html.css" - type="text/css"?> - <html><head><title>Error 404: File Not Found</title> - ...... etc... + b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html + ... + <title>Page Not Found</title>\n + ... Wrapping it Up -------------- |