mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
Clean up urlopen doc string.
Clarifies what is returned when and that the methods are common between the two. Patch by Alexander Liu as part of #22797.
This commit is contained in:
parent
13ee7d15e3
commit
d2367c651e
2 changed files with 7 additions and 6 deletions
|
|
@ -173,12 +173,7 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
|||
The *cadefault* parameter is ignored.
|
||||
|
||||
For http and https urls, this function returns a http.client.HTTPResponse
|
||||
object which has the following HTTPResponse Objects methods.
|
||||
|
||||
For ftp, file, and data urls and requests explicitly handled by legacy
|
||||
URLopener and FancyURLopener classes, this function returns a
|
||||
urllib.response.addinfourl object which can work as context manager and has
|
||||
methods such as:
|
||||
object which has the following HTTPResponse Objects methods:
|
||||
|
||||
* geturl() - return the URL of the resource retrieved, commonly used to
|
||||
determine if a redirect was followed
|
||||
|
|
@ -190,6 +185,11 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
|||
* getcode() - return the HTTP status code of the response. Raises URLError
|
||||
on errors.
|
||||
|
||||
For ftp, file, and data urls and requests explicitly handled by legacy
|
||||
URLopener and FancyURLopener classes, this function returns a
|
||||
urllib.response.addinfourl object which can work as context manager and
|
||||
also support the geturl(), info(), getcode() methods listed above.
|
||||
|
||||
Note that *None& may be returned if no handler handles the request (though
|
||||
the default installed global OpenerDirector uses UnknownHandler to ensure
|
||||
this never happens).
|
||||
|
|
|
|||
|
|
@ -884,6 +884,7 @@ Eric Lindvall
|
|||
Gregor Lingl
|
||||
Everett Lipman
|
||||
Mirko Liss
|
||||
Alexander Liu
|
||||
Nick Lockwood
|
||||
Stephanie Lockwood
|
||||
Martin von Löwis
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue