[New-bugs-announce] [issue14476] sudo breaks python

Pierre Ossman report at bugs.python.org
Mon Apr 2 16:57:06 CEST 2012


New submission from Pierre Ossman <ossman at cendio.se>:

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 at pangolin:~$ ./test.py
^Ca

But through sudo you get random behaviour:

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


Seen on Ubuntu 12.04 (alpha/beta) and on Fedora 16. Happens more often on Ubuntu though.

----------
components: Interpreter Core
messages: 157358
nosy: ossman
priority: normal
severity: normal
status: open
title: sudo breaks python
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14476>
_______________________________________


More information about the New-bugs-announce mailing list