[New-bugs-announce] [issue14425] Improve handling of 'timeout' parameter default in urllib.urlopen

R. David Murray report at bugs.python.org
Tue Mar 27 17:02:38 CEST 2012

New submission from R. David Murray <rdmurray at bitdance.com>:

Currently the prototype uses timeout=socket._GLOBAL_DEFAULT_TIMEOUT, and the docs give the prototype as:

  urlopen(url, data=None[, timeout], *, cafile=None, capath=None)

which is unlike most other Python function prototypes in the docs, and makes no sense from a python syntax point of view.  The current implementation makes it impossible to explicitly request the default timeout unless you look in the code and use the marked-private attribute of the socket module.

I suggest the prototype be changed to either timeout=None with an explanation that that means "use the default socket timeout", or to some public sentinel that can be passed explicitly.  I believe there are a number of other examples in the stdlib of None meaning "use the default", so I favor the former.

components: Library (Lib)
messages: 156932
nosy: orsenthil, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: Improve handling of 'timeout' parameter default in urllib.urlopen
type: enhancement
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list