Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 352219 - app-admin/checkrestart-0.47 doesn't work with Python 2.7
Summary: app-admin/checkrestart-0.47 doesn't work with Python 2.7
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: python-2.7
  Show dependency tree
 
Reported: 2011-01-20 10:52 UTC by Andrew Savchenko
Modified: 2011-02-12 17:51 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info,7.74 KB, text/plain)
2011-01-20 10:52 UTC, Andrew Savchenko
Details
fix for python 2.7 (due to bad programming practice) (checkrestart-0.47-list-comprehension-fix.patch,449 bytes, patch)
2011-02-11 17:46 UTC, Matthias Liebig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.