facebook/tornado — pull request #549 by polymorphm (2012-06-27 01:26:08+00:00)
Title: tornado.stack_context.wrap not must to restrict kwargs for function

``tornado.stack_context.wrap`` restricts kwargs for function

see this example:

import tornado.stack_context

def on_error(t, e, tb):
pass

with tornado.stack_context.ExceptionStackContext(on_error):
@tornado.stack_context.wrap
def test_func_A(my_callback=None):
print 'SUCCESS (A) !', my_callback

@tornado.stack_context.wrap
def test_func_B(callback=None):
print 'SUCCESS (B) !', callback

@tornado.stack_context.wrap
def test_func_C(contexts=None):
print 'SUCCESS (C) !', contexts

try:
test_func_A(my_callback='test A') # will be SUCCESS!
except Exception as e:
print 'ERROR: ', e

try:
test_func_B(callback='test B') # will be ERROR!
except Exception as e:
print 'ERROR: ', e

try:
test_func_C(contexts='test C') # will be ERROR!
except Exception as e:
print 'ERROR: ', e

output of this example is:

SUCCESS (A) ! test A
ERROR: wrapped() got multiple values for keyword argument 'callback'
ERROR: wrapped() got multiple values for keyword argument 'contexts'

this simple patch -- fixes this problem

thanks! :)