New submission from Pierre Ossman <oss...@cendio.se>:

These three things do not mix:

 - AttributeError
 - Threads
 - Object methods

An unhandled AttributeError thrown in a thread will not call sys.excepthook if 
the thread's start function is a class/object method.

Test case:


import sys
import thread

class Dummy:
        def worker(self):
                raise AttributeError

thread.start_new_thread(Dummy().worker, ())

sys.stdin.readline()


Note that you do not get a traceback here. Throwing any other exception type 
works fine, as does having worker() be a simple function.

I think I've traced the issue to Objects/classobject.c:instance_repr(). It 
tries to look up the method, making sure to handle any AttributeError this 
might cause. But it fails to save and restore and Exception currently already 
active, effectively clearing out the current exception.

----------
components: Interpreter Core
messages: 157350
nosy: ossman
priority: normal
severity: normal
status: open
title: mishandling of AttributeError in threads
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14474>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to