Fix in python3 _oauth_signature get invalid signature problem #581

wants to merge 2 commits into


None yet
2 participants

wynemo commented Aug 10, 2012

in python3, in the following statement


oauth_nonce 's type is bytes,
and in function _oauth_signature and _oauth10a_signature ,the following statement

base_elems.append("&".join("%s=%s" % (k, _oauth_escape(str(v)))
                               for k, v in sorted(parameters.items())))

use _oauth_escape(str(v)),when v 's type is bytes, str() will append b to the string


>>> print(str(binascii.b2a_hex(uuid.uuid4().bytes)))

so function _oauth_signature will return invalid signature

should convert oauth_nonce's type to str in python3(to unicode in python2 for compatibility)

wynemo added some commits Aug 10, 2012

@wynemo wynemo in python3 args['oauth_nonce']'s type is bytes,_oauth_signature will …
…get wrong result,should convert its' type to str

_oauth_escape(str(v)) in function _oauth_signature,if v's type is bytes,str() will append b to the string
@wynemo wynemo the other two places should also use str type in python3 4074de8

bdarnell commented Aug 12, 2012

This turned out to be an example of a broader issue; I've had to fix up a few more places as well (but after some wrestling with the unittest module we will now get an error when this kind of thing happens)

bdarnell closed this in ec49816 Aug 12, 2012

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