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.

Title: sudo breaks python
Type: Stage: resolved
Components: Interpreter Core Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, ossman, r.david.murray, tshepang
Priority: normal Keywords:

Created on 2012-04-02 14:57 by ossman, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg157358 - (view) Author: Pierre Ossman (ossman) Date: 2012-04-02 14:57
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:


import time

def a():
		while True:
	except KeyboardInterrupt:
		print "a"

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


This is expected:

pierre@pangolin:~$ ./

But through sudo you get random behaviour:

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

Seen on Ubuntu 12.04 (alpha/beta) and on Fedora 16. Happens more often on Ubuntu though.
msg157360 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-04-02 15:02
It's probably not related to Python; see
This threads ends with: """
   Great.  That change will be in the next sudo release.
msg157361 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-02 15:10
See also, which lists versions.  Sounds like the same bug Amaury linked to.
msg157362 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-02 15:11
I'm going to close this.  If it turns out not to be a bug in sudo, please reopen.
msg157364 - (view) Author: Pierre Ossman (ossman) Date: 2012-04-02 15:15
Well that was fast. :)

Sounds very much like the same bug I'm seeing here, yes. Unfortunately I'm not sure it's sufficient for us to rely on the distributions to update their sudo packages. A workaround would be preferable. I'll see if I can figure something out.

Many thanks!
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58681
2012-04-02 15:15:39ossmansetmessages: + msg157364
2012-04-02 15:11:49r.david.murraysetstatus: open -> closed
resolution: not a bug
messages: + msg157362

stage: resolved
2012-04-02 15:10:33r.david.murraysetnosy: + r.david.murray
messages: + msg157361
2012-04-02 15:02:38amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg157360
2012-04-02 14:59:54tshepangsetnosy: + tshepang
2012-04-02 14:57:05ossmancreate