[Bug 1046438] [NEW] Stack trace when package has no candidate in debug mode

Marc Tardif marc.tardif at ubuntu.com
Wed Sep 5 17:11:44 UTC 2012


Public bug reported:

This is what I get when running unattended-upgrades --debug:

Initial blacklisted packages:
Starting unattended upgrades script
...
Traceback (most recent call last):
  File "/usr/bin/unattended-upgrades", line 491, in <module>
    main()
  File "/usr/bin/unattended-upgrades", line 292, in main
    logging.debug("Checking: %s (%s)" % (pkg.name, map(str,
pkg.candidate.origins)))
AttributeError: 'NoneType' object has no attribute 'origins'

The problem is that the unattended-upgrades script doesn't check the
value of pkg.candidate before calling the origins attribute on it. As
can be seen in the apt.package.Package class, the candidate attribute
might be None:

    def candidate(self):
        """Return the candidate version of the package.

        This property is writeable to allow you to set the candidate version
        of the package. Just assign a Version() object, and it will be set as
        the candidate version.
        """
        cand = self._pcache._depcache.get_candidate_ver(self._pkg)
        if cand is not None:
            return Version(self, cand)

Therefore, the unattended-upgrades script should expect this eventually.
This can easily be done by using getattr and returning an empty list
there are no candidates.

** Affects: unattended-upgrades (Ubuntu)
     Importance: Undecided
         Status: New

** Branch linked: lp:~cr3/ubuntu/quantal/unattended-upgrades/1046438

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to unattended-upgrades in Ubuntu.
https://bugs.launchpad.net/bugs/1046438

Title:
  Stack trace when package has no candidate in debug mode

Status in “unattended-upgrades” package in Ubuntu:
  New

Bug description:
  This is what I get when running unattended-upgrades --debug:

  Initial blacklisted packages:
  Starting unattended upgrades script
  ...
  Traceback (most recent call last):
    File "/usr/bin/unattended-upgrades", line 491, in <module>
      main()
    File "/usr/bin/unattended-upgrades", line 292, in main
      logging.debug("Checking: %s (%s)" % (pkg.name, map(str,
  pkg.candidate.origins)))
  AttributeError: 'NoneType' object has no attribute 'origins'

  The problem is that the unattended-upgrades script doesn't check the
  value of pkg.candidate before calling the origins attribute on it. As
  can be seen in the apt.package.Package class, the candidate attribute
  might be None:

      def candidate(self):
          """Return the candidate version of the package.

          This property is writeable to allow you to set the candidate version
          of the package. Just assign a Version() object, and it will be set as
          the candidate version.
          """
          cand = self._pcache._depcache.get_candidate_ver(self._pkg)
          if cand is not None:
              return Version(self, cand)

  Therefore, the unattended-upgrades script should expect this
  eventually. This can easily be done by using getattr and returning an
  empty list there are no candidates.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1046438/+subscriptions




More information about the foundations-bugs mailing list