[New-bugs-announce] [issue29096] Signal Handlers reliably cause UnboundLocalErrors
Ted Meyer
report at bugs.python.org
Wed Dec 28 15:38:35 EST 2016
New submission from Ted Meyer:
Using this simple snippit of code:
import signal
import signal
def sig_hdlr(signum, frame):
raise ValueError()
def faulty():
local_var = ""
signal.signal(signal.SIGALRM, sig_hdlr)
signal.alarm(1)
try:
while True:
local_var += "!"
except ValueError:
print (local_val)
faulty()
I can reliably get a crash:
tmathmeyer at tmathmeyer-linuxstation:~$ python --version
Python 2.7.6
tmathmeyer at tmathmeyer-linuxstation:~$ python pybug.py
Traceback (most recent call last):
File "pybug.py", line 16, in <module>
faulty()
File "pybug.py", line 14, in faulty
print local_val
NameError: global name 'local_val' is not defined
tmathmeyer at tmathmeyer-linuxstation:~$ python3.4 pybug.py
Traceback (most recent call last):
File "pybug.py", line 12, in faulty
local_var += "!"
File "pybug.py", line 4, in sig_hdlr
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pybug.py", line 16, in <module>
faulty()
File "pybug.py", line 14, in faulty
print (local_val)
NameError: name 'local_val' is not defined
I can repro this on 2.7.6 and 3.4, but do not have other versions to test on.
----------
messages: 284196
nosy: Ted Meyer
priority: normal
severity: normal
status: open
title: Signal Handlers reliably cause UnboundLocalErrors
versions: Python 2.7, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29096>
_______________________________________
More information about the New-bugs-announce
mailing list