[New-bugs-announce] [issue4079] new urllib2.Request 'timeout' attribute needs to have a default

Sidnei da Silva report at bugs.python.org
Wed Oct 8 20:29:59 CEST 2008

New submission from Sidnei da Silva <sidnei.da.silva at gmail.com>:

'urllib2' has introduced a configurable 'timeout' setting by assigning
to the 'timeout' attribute of the urllib2.Request object. However the
implementation is flawed:

- the 'timeout' attribute is set in OpenerDirector.open() and nowhere else

- if someone overrides OpenerDirector.open() (btw: mechanize does
  this), then the 'timeout' attribute will never be set, breaking
  other parts of the code which require the 'timeout' attribute to be

A simple workaround for this would be to do one or more of:

a) define the 'timeout' attribute as socket._GLOBAL_DEFAULT_TIMEOUT at

b) initialize the 'timeout' attribute on urllib2.Request.__init__()

components: Library (Lib)
messages: 74541
nosy: sidnei
severity: normal
status: open
title: new urllib2.Request 'timeout' attribute needs to have a default
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list