[issue11140] threading.Lock().release() raises _thread.error, not RuntimeError

Antoine Pitrou report at bugs.python.org
Mon Feb 7 17:11:21 CET 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

> aaugustin <aymeric.augustin at polyconseil.fr> added the comment:
> 
> I agree with your solution. Unfortunately, I do not know how you would
> redefine ThreadError to extend RuntimeError in a C extension.
> 
> _thread.error is created line 741 in trunk/Modules/threadmodule.c:
> ThreadError = PyErr_NewException("thread.error", NULL, NULL);

I was not proposing to extend it, just to alias it:

ThreadError = PyExc_RuntimeError;
Py_INCREF(ThreadError);

That said, extending is quite trivial if the behaviour is not changed:

ThreadError = PyErr_NewException("thread.error", PyExc_RuntimeError,
NULL);

(see
http://docs.python.org/dev/c-api/exceptions.html#PyErr_NewException)

----------

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


More information about the Python-bugs-list mailing list