Merge lp:~jelmer/bzr-builddeb/fix-restart into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jelmer/bzr-builddeb/fix-restart
Merge into: lp:bzr-builddeb
Diff against target: 19 lines (+3/-3)
1 file modified
upstream.py (+3/-3)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/fix-restart
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+23195@code.launchpad.net

Description of the change

This fixes three places where we were calling getattr() to deal with renames in apt_pkg but specified only two arguments.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

 review: needsfixing

This will change a failure from an attribute error to a 'None is not
callable' error - hardly an improvement.

Either also guard the result against being None, or just leave it alone
- it looks fine to me.

-Rob

review: Needs Fixing
Revision history for this message
Robert Collins (lifeless) wrote :

 review: +1

Oh, argh, I see the issue - perhaps. Is the case you're dealing with
that the second getattr is looked up before the first, as its passed
into the first/outer one, so the compatability code only works one way
at the moment?

-Rob

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Sun, 2010-04-11 at 22:18 +0000, Robert Collins wrote:
> Review: Approve
> review: +1
>
> Oh, argh, I see the issue - perhaps. Is the case you're dealing with
> that the second getattr is looked up before the first, as its passed
> into the first/outer one, so the compatability code only works one way
> at the moment?
Yep, that's indeed what I intended to fix. The author probably had the
function in the second getattr present so never saw the AttributeError,
as the first getattr has three arguments and never raises
AttributeError.

Cheers,

Jelmer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'upstream.py'
2--- upstream.py 2010-03-30 18:36:31 +0000
3+++ upstream.py 2010-04-11 21:02:14 +0000
4@@ -115,12 +115,12 @@
5 except SystemError:
6 raise PackageVersionNotPresent(package, upstream_version, self)
7
8- restart = getattr(sources, 'restart', getattr(sources, 'Restart'))
9+ restart = getattr(sources, 'restart', getattr(sources, 'Restart', None))
10 restart()
11 note("Using apt to look for the upstream tarball.")
12- lookup = getattr(sources, 'lookup', getattr(sources, 'Lookup'))
13+ lookup = getattr(sources, 'lookup', getattr(sources, 'Lookup', None))
14 while lookup(package):
15- version = getattr(sources, 'version', getattr(sources, 'Version'))
16+ version = getattr(sources, 'version', getattr(sources, 'Version', None))
17 if upstream_version == Version(version).upstream_version:
18 if self._run_apt_source(package, version, target_dir):
19 return

Subscribers

People subscribed via source and target branches