Message ID | 1542133569-8223-1-git-send-email-kamal@canonical.com |
---|---|
State | New |
Headers | show |
Series | [kteam-tools] ktl: fix new-package crash: no attribute 'stakeholder' | expand |
On Tue, Nov 13, 2018 at 10:26:09AM -0800, Kamal Mostafa wrote: > Fix crashes when using create-release-tracker --new-package. > > Be more careful to not dereference possible NoneType returns from LP API > (as for brand new packages) when looking for the 'stakeholder' attribute. > > File "/home/kamal/src/ckt/kteam-tools/stable/ktl/workflow.py", in assignee_ex > cursor = cursor.lookup_source(packagename) > retval = cursor.stakeholder > > AttributeError: 'NoneType' object has no attribute 'stakeholder' > > Signed-off-by: Kamal Mostafa <kamal@canonical.com> > --- > ktl/tracking_bug.py | 2 +- > ktl/workflow.py | 5 +++-- > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py > index efea367..bd26f79 100644 > --- a/ktl/tracking_bug.py > +++ b/ktl/tracking_bug.py > @@ -109,7 +109,7 @@ class TrackingBug: > if lp_series.name == 'stakeholder-signoff': > cursor = self.kernel_series.lookup_series(codename=targeted_series_name) > cursor = cursor.lookup_source(package) > - if cursor.stakeholder is None: > + if cursor and cursor.stakeholder is None: As a general rule you should do comparisons against None using is [not] None: if cursor is not None and cursor.stakeholder is None: > cdebug(' no stakeholder-signoff', 'yellow') > break > if lp_series.name == 'promote-to-release' and not self.isdev: > diff --git a/ktl/workflow.py b/ktl/workflow.py > index b71e02f..76f83b0 100644 > --- a/ktl/workflow.py > +++ b/ktl/workflow.py > @@ -231,8 +231,9 @@ class Workflow: > ks = KernelSeries() > cursor = ks.lookup_series(codename=series_codename) > cursor = cursor.lookup_source(packagename) > - retval = cursor.stakeholder > - else: > + if cursor: And here. > + retval = cursor.stakeholder > + if not retval: > retval = self.assignee(packagename, taskname, devel) > return retval > > -- With those fixed: Acked-by: Andy Whitcroft <apw@canonical.com> -apw
Applied, with Andy's suggestions. -Kamal On Tue, Nov 13, 2018 at 10:26:09AM -0800, Kamal Mostafa wrote: > Fix crashes when using create-release-tracker --new-package. > > Be more careful to not dereference possible NoneType returns from LP API > (as for brand new packages) when looking for the 'stakeholder' attribute. > > File "/home/kamal/src/ckt/kteam-tools/stable/ktl/workflow.py", in assignee_ex > cursor = cursor.lookup_source(packagename) > retval = cursor.stakeholder > > AttributeError: 'NoneType' object has no attribute 'stakeholder' > > Signed-off-by: Kamal Mostafa <kamal@canonical.com> > --- > ktl/tracking_bug.py | 2 +- > ktl/workflow.py | 5 +++-- > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py > index efea367..bd26f79 100644 > --- a/ktl/tracking_bug.py > +++ b/ktl/tracking_bug.py > @@ -109,7 +109,7 @@ class TrackingBug: > if lp_series.name == 'stakeholder-signoff': > cursor = self.kernel_series.lookup_series(codename=targeted_series_name) > cursor = cursor.lookup_source(package) > - if cursor.stakeholder is None: > + if cursor and cursor.stakeholder is None: > cdebug(' no stakeholder-signoff', 'yellow') > break > if lp_series.name == 'promote-to-release' and not self.isdev: > diff --git a/ktl/workflow.py b/ktl/workflow.py > index b71e02f..76f83b0 100644 > --- a/ktl/workflow.py > +++ b/ktl/workflow.py > @@ -231,8 +231,9 @@ class Workflow: > ks = KernelSeries() > cursor = ks.lookup_series(codename=series_codename) > cursor = cursor.lookup_source(packagename) > - retval = cursor.stakeholder > - else: > + if cursor: > + retval = cursor.stakeholder > + if not retval: > retval = self.assignee(packagename, taskname, devel) > return retval > > -- > 2.7.4 >
diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py index efea367..bd26f79 100644 --- a/ktl/tracking_bug.py +++ b/ktl/tracking_bug.py @@ -109,7 +109,7 @@ class TrackingBug: if lp_series.name == 'stakeholder-signoff': cursor = self.kernel_series.lookup_series(codename=targeted_series_name) cursor = cursor.lookup_source(package) - if cursor.stakeholder is None: + if cursor and cursor.stakeholder is None: cdebug(' no stakeholder-signoff', 'yellow') break if lp_series.name == 'promote-to-release' and not self.isdev: diff --git a/ktl/workflow.py b/ktl/workflow.py index b71e02f..76f83b0 100644 --- a/ktl/workflow.py +++ b/ktl/workflow.py @@ -231,8 +231,9 @@ class Workflow: ks = KernelSeries() cursor = ks.lookup_series(codename=series_codename) cursor = cursor.lookup_source(packagename) - retval = cursor.stakeholder - else: + if cursor: + retval = cursor.stakeholder + if not retval: retval = self.assignee(packagename, taskname, devel) return retval
Fix crashes when using create-release-tracker --new-package. Be more careful to not dereference possible NoneType returns from LP API (as for brand new packages) when looking for the 'stakeholder' attribute. File "/home/kamal/src/ckt/kteam-tools/stable/ktl/workflow.py", in assignee_ex cursor = cursor.lookup_source(packagename) retval = cursor.stakeholder AttributeError: 'NoneType' object has no attribute 'stakeholder' Signed-off-by: Kamal Mostafa <kamal@canonical.com> --- ktl/tracking_bug.py | 2 +- ktl/workflow.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)