URLError handling with urllib can fail

Bug #59835 reported by Robert Collins
4
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
Vincent Ladeuil

Bug Description

On Thu, 2006-08-31 at 18:49 +0200, Christian Bjälevik wrote:
> Format <RepositoryFormat6> for
> http://people.ubuntu.com/~mvo/bzr/update-manager/update-manager--dapper/.bzr/ is deprecated - please use 'bzr upgrade' to get better performance
> bzr: ERROR: exceptions.AttributeError: URLError instance has no
> attribute 'code'
> ...

> File
> "/usr/lib/python2.4/site-packages/bzrlib/transport/http/_urllib.py",
> line 117, in has
> mutter('url error code: %s for has url: %r', e.code, abspath)
> AttributeError: URLError instance has no attribute 'code'
> bzr 0.9.0 on python 2.4.3.final.0 (linux2)
> arguments: ['/usr/bin/bzr', 'branch',
> 'http://people.ubuntu.com/~mvo/bzr/update-manager/update-manager--dapper/', 'dapper']

Looks like a HTTP error of some sort happened during access to the
branch, and it did not have a .code attribute so rather than being
handled it threw all the way up.

mvo should do 'bzr upgrade' to that branch as a separate issue.

 affects /products/bzr

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Vincent Ladeuil (vila) wrote :

I encounter the same scenario while working on the urllib-based webdav plugin implementation.

It occurs more often when a connection is kept alive.
The error is caused by:
- the server not responding,
- httplib trying to read the status line, failing and throwing a BadStatusLine exception.

So of course there is no 'code', it's part of the status line.
Also, Robert is right, it's an HTTP error.

If this bug becomes critical, I can try to provide a patch, but I doubt it, it occurs pretty rarely.

Revision history for this message
John A Meinel (jameinel) wrote :

It is a real bug that we try to access 'e.code' on an error that doesn't have that member. It should be changed to either catch HTTPError, or to use getattr(e, 'code', None).

Either way, we want to raise a real error, not an attribute error.

Revision history for this message
Vincent Ladeuil (vila) wrote :

I was wrong with my previous comment, this bug is unrelated with one I described (BadStatusLine).

My apologies and a patch attached.

Revision history for this message
Vincent Ladeuil (vila) wrote :

see also https://launchpad.net/products/bzr/+bug/42407

is there a better way to link bugs than mentioning their url ?

Changed in bzr:
status: Unconfirmed → Confirmed
importance: Untriaged → Low
Revision history for this message
John A Meinel (jameinel) wrote :

bug 42407
Works for me.

Changed in bzr:
assignee: nobody → v-ladeuil
status: Confirmed → Fix Released
Revision history for this message
Vincent Ladeuil (vila) wrote :

just typing bug 42407 or bug #42407, no preview, more spam, sorry all, hi john :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.