This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ossman
Recipients ossman
Date 2012-04-02.14:57:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333378626.33.0.624726791004.issue14476@psf.upfronthosting.co.za>
In-reply-to
Content
sudo breaks exception handling in Python in some subtle way. The following test program works fine when run directly, but breaks when run through sudo:


#!/usr/bin/python

import time

def a():
	try:
		while True:
			time.sleep(0.001)
	except KeyboardInterrupt:
		print "a"

def b():
	try:
		a()
	except KeyboardInterrupt:
		print "b"

b()


This is expected:

pierre@pangolin:~$ ./test.py
^Ca

But through sudo you get random behaviour:

pierre@pangolin:~$ sudo ./test.py
^Ca b
pierre@pangolin:~$ sudo ./test.py
^Ca b
pierre@pangolin:~$ sudo ./test.py
^Ca
b
pierre@pangolin:~$ sudo ./test.py
^Ca
pierre@pangolin:~$ sudo ./test.py
^Ca
pierre@pangolin:~$ sudo ./test.py
^Cb


Seen on Ubuntu 12.04 (alpha/beta) and on Fedora 16. Happens more often on Ubuntu though.
History
Date User Action Args
2012-04-02 14:57:06ossmansetrecipients: + ossman
2012-04-02 14:57:06ossmansetmessageid: <1333378626.33.0.624726791004.issue14476@psf.upfronthosting.co.za>
2012-04-02 14:57:05ossmanlinkissue14476 messages
2012-04-02 14:57:05ossmancreate