Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 352219

Summary: app-admin/checkrestart-0.47 doesn't work with Python 2.7
Product: Gentoo Linux Reporter: Andrew Savchenko <bircoph>
Component: Current packagesAssignee: Jeroen Roovers (RETIRED) <jer>
Status: RESOLVED FIXED    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 292401    
Attachments: emerge --info
fix for python 2.7 (due to bad programming practice)

Description Andrew Savchenko gentoo-dev 2011-01-20 10:52:04 UTC
Hello,

After upgrade to python-2.7.1 checkrestart fails:

# checkrestart 
lsof: WARNING: can't stat() fuse.sshfs file system /home/andrew/sshfs/orionis
      Output information may be incomplete.
Found 64 processes using old versions of upgraded files
(37 distinct programs)
(17 distinct packages)
Traceback (most recent call last):
  File "/usr/sbin/checkrestart", line 495, in <module>
    main()
  File "/usr/sbin/checkrestart", line 219, in main
    package.initscripts = [ u for u in package.initscripts if u not in locals()['_[1]'] ]
KeyError: '_[1]'

$ eselect python list
Available Python interpreters:
  [1]   python2.6
  [2]   python2.7 *
  [3]   python3.1

With python2.6 it works well. python-updater was used. I reinstalled checkrestart manually, but with no effect.
Comment 1 Andrew Savchenko gentoo-dev 2011-01-20 10:52:37 UTC
Created attachment 260345 [details]
emerge --info
Comment 2 Matthias Liebig 2011-02-11 17:46:37 UTC
Created attachment 262139 [details, diff]
fix for python 2.7 (due to bad programming practice)

From http://docs.python.org/reference/expressions.html:
"In Python 2.3 and later releases, a list comprehension "leaks" the control variables of each for it contains into the containing scope. However, this behavior is deprecated, and relying on it will not work in Python 3.0"

The author relied on an obscure feature (explained here: http://code.activestate.com/recipes/204297-the-secret-name-of-list-comprehensions/) and should be notified. My suggestion would be to consistently use the "set" data type to prevent duplicate entries.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2011-02-12 17:37:34 UTC
Thanks for the patch. I trust it works for python 2.7 as it does for 2.6, which I tested with. It's applied in -r1.