natty: checkrestart: line 191, in main: package.initscripts = [ u for u in package.initscripts if u not in locals()['_[1]'] ]; KeyError: '_[1]'

Bug #764042 reported by Kenyon Ralph
46
This bug affects 8 people
Affects Status Importance Assigned to Milestone
debian-goodies (Debian)
Fix Released
Unknown
debian-goodies (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: debian-goodies

checkrestart worked in maverick. I upgraded to natty beta 2 a couple of days ago, and checkrestart now throws an exception.

kenyon@voodoo ~ % lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu Natty (development branch)
Release: 11.04
Codename: natty

kenyon@voodoo ~ % sudo checkrestart
Found 19 processes using old versions of upgraded files
(9 distinct programs)
(9 distinct packages)
Traceback (most recent call last):
  File "/usr/sbin/checkrestart", line 459, in <module>
    main()
  File "/usr/sbin/checkrestart", line 191, in main
    package.initscripts = [ u for u in package.initscripts if u not in locals()['_[1]'] ]
KeyError: '_[1]'

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: debian-goodies 0.55
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic i686
Architecture: i386
Date: Sun Apr 17 15:33:24 2011
PackageArchitecture: all
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/sh
SourcePackage: debian-goodies
UpgradeStatus: Upgraded to natty on 2011-04-16 (1 days ago)

Revision history for this message
Kenyon Ralph (kralph) wrote :
summary: - natty: line 191, in main: package.initscripts = [ u for u in
- package.initscripts if u not in locals()['_[1]'] ]; KeyError: '_[1]'
+ natty: checkrestart: line 191, in main: package.initscripts = [ u for u
+ in package.initscripts if u not in locals()['_[1]'] ]; KeyError: '_[1]'
Revision history for this message
Axel Beckert (xtaran) wrote : Re: [Bug 764042] [NEW] natty: checkrestart: line 191, in main: package.initscripts = [ u for u in package.initscripts if u not in locals()['_[1]'] ]; KeyError: '_[1]'

Hi,

Kenyon Ralph wrote:
> kenyon@voodoo ~ % sudo checkrestart
> Found 19 processes using old versions of upgraded files
> (9 distinct programs)
> (9 distinct packages)
> Traceback (most recent call last):
> File "/usr/sbin/checkrestart", line 459, in <module>
> main()
> File "/usr/sbin/checkrestart", line 191, in main
> package.initscripts = [ u for u in package.initscripts if u not in locals()['_[1]'] ]
> KeyError: '_[1]'

Can't reproduce this in Debian Unstable, neither with Python 2.5, 2.6
nor 2.7, neither with nor without sudo. So it may be an
ubuntu-specific bug.

Information about the used version of python and other dependencies of
debian-goodies may be helpful.

  Regards, Axel
--
 ,''`. | Axel Beckert <email address hidden>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
  `- | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5

Revision history for this message
Axel Beckert (xtaran) wrote :

Hi,

Axel Beckert wrote:
> Information about the used version of python and other dependencies of
> debian-goodies may be helpful.

Found them at https://launchpadlibrarian.net/69752128/Dependencies.txt
-- they weren't included in the mails. :-(

  Regards, Axel
--
 ,''`. | Axel Beckert <email address hidden>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
  `- | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5

Revision history for this message
Kenyon Ralph (kralph) wrote :

I'm not sure why line 191 had an error for me, I didn't really investigate how it works, but replacing it with a simpler method of removing duplicates fixes the problem:

package.initscripts = list(set(package.initscripts))

Attached is a patch with that change, against the debian-goodies 0.55 version of checkrestart. I added a similar line to remove duplicate init script listings, which can happen when checkrestart finds that openssh-client and openssh-server both need to be restarted, /etc/init.d/ssh will be listed twice, for example. Also, I did a whitespace-cleanup using emacs.

Note that this usage of set() requires python >= 2.5. http://docs.python.org/faq/programming.html#how-do-you-remove-duplicates-from-a-list

tags: added: patch
Revision history for this message
Han Boetes (han-mijncomputer) wrote :

I think that Kenyon Ralph's patch fixes the issue.

Daniel T Chen (crimsun)
Changed in debian-goodies (Ubuntu):
status: New → Triaged
Revision history for this message
Kenyon Ralph (kralph) wrote :

I'm not seeing this problem (the Python exception on line 191 of checkrestart) at the moment with Ubuntu oneiric and debian-goodies 0.55.

Revision history for this message
Kenyon Ralph (kralph) wrote :

Nope, I still see this problem on oneiric, and my patch still fixes it.

Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :

I have two Ubuntu oneiric systems and this bug only shows up on one of them. I wonder what could explain that.

Revision history for this message
Kenyon Ralph (kralph) wrote : Re: [Bug 764042] Re: natty: checkrestart: line 191, in main: package.initscripts = [ u for u in package.initscripts if u not in locals()['_[1]'] ]; KeyError: '_[1]'

On 2011-11-29T07:46:17-0000, Laurent Bonnaud <email address hidden> wrote:
> I have two Ubuntu oneiric systems and this bug only shows up on one of
> them. I wonder what could explain that.

The bug doesn't occur all the time. I think it depends on the state of
the system, that is, the input to checkrestart. So it probably will
occur on your other system eventually.

--
Kenyon Ralph

Revision history for this message
Sebastian Bugiu (sebastian-bugiu) wrote :

Yep I just got it also today! The thing is it worked. Last time I used it was maybe a week ago at most. Now it doesn't work anymore. Could it be some recent update? I have to mention I haven't restarted the system in over 100 days now and can't restart it to test if maybe some updates got mangled.

Revision history for this message
Kenyon Ralph (kralph) wrote :

On 2012-03-04T00:09:16-0000, Sebastian Bugiu <email address hidden> wrote:
> Yep I just got it also today! The thing is it worked. Last time I used
> it was maybe a week ago at most. Now it doesn't work anymore. Could it
> be some recent update? I have to mention I haven't restarted the system
> in over 100 days now and can't restart it to test if maybe some updates
> got mangled.

It's the lsof output that causes this bug with checkrestart, not the
package upgrades. Try my patch from comment #4.

--
Kenyon Ralph

Revision history for this message
Axel Beckert (xtaran) wrote :

This has been fixed in debian-goodies 0.56 and since 0.59 is in Precise, this should be fixed in Precise.

Changed in debian-goodies (Ubuntu):
status: Triaged → Fix Released
Changed in debian-goodies (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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