Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

default argument order fix #4

merged 3 commits into from Jan 24, 2014


None yet
3 participants

koelie commented Mar 13, 2013

following up on my msg on the google groups, this is a fix for the order default arguments are set in. Currently they are set in reverse order as the following example shows:

server code:

from tornadorpc.json import JSONRPCHandler
from tornadorpc import start_server
class Handler(JSONRPCHandler):
def test(self, a=1, b=2, c=3, d=4):
return {'a': a, 'b': b, 'c': c, 'd': d}
start_server(Handler, port=8888)

client code:

import jsonrpclib
server = jsonrpclib.Server('http://localhost:8888')
print server.test()
print server.test(a='one')
print server.test(d='four')
print server.test(a='one',b='two',c='three',d='four')

This prints (unicode markers removed for readability):
{'a': 4, 'c': 2, 'b': 3, 'd': 1}
{'a': 'one', 'c': 2, 'b': 3, 'd': 1}
{'a': 4, 'c': 2, 'b': 3, 'd': 'four'}
{'a': 'one', 'c': 'three', 'b': 'two', 'd': 'four'}

note that the defaults are set in reverse order. My patch fixes this.


joshmarshall commented Mar 13, 2013

Hey koelle -- thanks for this! Do you think you could provide a test for this behavior as well, so we make sure we don't squash it later?


koelie commented Mar 16, 2013

test added

bryndin commented Jan 24, 2014

Hi Josh, can you add this fix to your tornadorpc? The version I'm getting still have the issue.
Meanwhile I can use koelie's fork.

@joshmarshall joshmarshall added a commit that referenced this pull request Jan 24, 2014

@joshmarshall joshmarshall Merge pull request #4 from koelie/master
default argument order fix

@joshmarshall joshmarshall merged commit ea6a8f3 into joshmarshall:master Jan 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment