[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
  present.

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

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

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>
<http://bugs.python.org/issue4079>
_______________________________________


More information about the Python-bugs-list mailing list