Barry A. Warsaw added the comment: On Jul 10, 2013, at 05:53 AM, R. David Murray wrote:
>Please see issue 14425 and then let us know if this is still valid. It's >been a while since I looked at the code and I no longer remember the details, >but I seemed confident in my conclusion at the time... :) I'm not sure I completely understand the arguments in #14425 and #2451 which it refers to. I could be wrong, but it seems to me that these are arguing against using socket.getdefaulttimeout() in favor of the magic non-public attribute that's currently being used. While I don't like that particular aspect, it's not the real point of *this* bug. Even if socket._GLOBAL_DEFAULT_TIMEOUT is the effective default for `timeout`, I still think using that as the default value for the keyword argument is wrong, both for usability of this API and for the documentation of it. I don't see why `timeout=None` wouldn't be acceptable, but let's assume it isn't. A documented, public sentinel would be acceptable and it could either be defined as: DEFAULT_TIMEOUT = object() or DEFAULT_TIMEOUT = socket._GLOBAL_DEFAULT_TIMEOUT With the latter, the function's signature would then change to: def urlopen(url, data=None, timeout=DEFAULT_TIMEOUT, ...) and nothing functional would change. The documentation update would be much more helpful too. If it weren't for the new module attribute, it could probably even be backported. Then users of this module could do something like this: from urllib.request import DEFAULT_TIMEOUT, urlopen def my_open(url, timeout=None): my_timeout = DEFAULT_TIMEOUT if timeout is None else timeout return urlopen(url, timeout=my_timeout) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18417> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com