[Yum-devel] [UG] python 2.2 and TimeoutError
Michael Stenner
mstenner at linux.duke.edu
Tue Jul 12 18:15:22 UTC 2005
On Tue, Jul 12, 2005 at 03:24:26AM +0300, Pekka Pessi wrote:
> urlgrabber fails to produce any meaningful diagnostics when a network
> error occurs on systems with python 2.2 (or earlier). This is because
> TimeoutError is None, which is not a valid argument to isinstance(), for
> instance.
Thanks, although I'm a little confused. TimeoutError is only used
three times (including definition):
=======================================================================
try:
TimeoutError = socket.timeout
have_socket_timeout = True
except AttributeError:
TimeoutError = None
have_socket_timeout = False
=======================================================================
except IOError, e:
if hasattr(e, 'reason') and have_socket_timeout and \
isinstance(e.reason, TimeoutError):
=======================================================================
except TimeoutError, e:
raise URLGrabError(12, _('Timeout: %s') % (e, ))
=======================================================================
The first time is obviously not a direct problem. The second, it
should be protected by the "have_socket_timeout" check. The third
time shouldn't be a problem either, as it's fine to do
except None, e:
<stuff>
Your suggested change doesn't appear to be problematic at all. I just
want to understand what's going on :)
-Michael
> diff -u grabber.py.orig grabber.py
> --- grabber.py.orig 2005-01-25 10:08:15.000000000 +0200
> +++ grabber.py 2005-07-12 03:16:28.000000000 +0300
> @@ -339,7 +339,8 @@
> TimeoutError = socket.timeout
> have_socket_timeout = True
> except AttributeError:
> - TimeoutError = None
> + class TimeoutError:
> + pass
> have_socket_timeout = False
>
> class URLGrabError(IOError):
--
Michael D. Stenner mstenner at ece.arizona.edu
ECE Department, the University of Arizona 520-626-1619
1230 E. Speedway Blvd., Tucson, AZ 85721-0104 ECE 524G
More information about the Yum-devel
mailing list