[New-bugs-announce] [issue18417] urlopen() has a hidden default for its timeout argument

Barry A. Warsaw report at bugs.python.org
Tue Jul 9 22:11:09 CEST 2013


New submission from Barry A. Warsaw:

urllib.request.urlopen() takes a `timeout` argument with a default value, but the default value is "hidden" and undocumented.  As implemented, the value is socket._GLOBAL_DEFAULT_TIMEOUT, but even this isn't really correct or useful.

The problem comes if you are passing a set of arguments to urlopen() and want to pass in a timeout that is the same as default.  Because its undocumented, you have to UTSL to figure out what the value is, and then you have to use a non-public attribute of the socket module.

It would be better if urlopen() was documented to default `timeout=None` meaning "use the default timeout".  The implementation should then use socket.getdefaulttimeout() when timeout=None.

The documentation should also be updated.

Now if you want to call urlopen() with the default values, it would just be `urlopen(..., timeout=None, ...)`

----------
messages: 192773
nosy: barry
priority: normal
severity: normal
status: open
title: urlopen() has a hidden default for its timeout argument
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18417>
_______________________________________


More information about the New-bugs-announce mailing list