"Diez B. Roggisch" <dee,,eb.de> wrote: > Hendrik van Rooyen wrote: > > It would have been nice, however, to have gotten something like: > > > > TypeError - This routine needs a tuple. > > > > instead of the silent in line calling of the routine in question, > > while failing actually to start a new thread. > > You can't prevent the silent inline-calling - otherwise, how would you do > this: > > def compute_thread_target(): > def target(): > pass > return target > > thread.start_new_thread(compute_thread_target()) > > > Of course start_new_thread could throw an error if it got nothing callable > as first argument. No idea why it doesn't.
Thanks - got it, I think. Doesn't mean I like it, though: >>> a = 42 >>> b = 24 >>> def do_something(c,d): print c print d >>> do_something(a,b) 42 24 >>> def harmless(): return a >>> def evil(): while True: pass >>> do_something(a) Traceback (most recent call last): File "<pyshell#15>", line 1, in ? do_something(a) TypeError: do_something() takes exactly 2 arguments (1 given) >>> do_something(harmless()) Traceback (most recent call last): File "<pyshell#17>", line 1, in ? do_something(harmless()) TypeError: do_something() takes exactly 2 arguments (1 given) >>>do_something(evil()) This hangs and needs OS intervention to kill it - and there is also just one argument, not two. Looks like the arguments are handled one by one without validation till the end. Lets see: >>> do_something(a,b,harmless()) Traceback (most recent call last): File "<pyshell#18>", line 1, in ? do_something(a,b,harmless()) TypeError: do_something() takes exactly 2 arguments (3 given) So far, so good. >>>do_something(a,b,evil()) This also hangs - the third, extra argument is actually called! Are you all sure this is not a buglet? - Hendrik -- http://mail.python.org/mailman/listinfo/python-list