google / gdata-python-client

444 stars 228 forks source link

auth.py uses bytearray.tostring, which doesn't seem to exist #37

Closed trinarytree closed 8 years ago

trinarytree commented 8 years ago

auth.py uses tostring in exactly 1 place, which causes the following test to fail for me:

ERROR: testSecureAuthSubGetAuthHeader (gdata_tests.auth_test.TokenClassesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ccalabro/code/python/gdata-python-client/tests/gdata_tests/auth_test.py", line 514, in testSecureAuthSubGetAuthHeader
    auth_header = token.GetAuthHeader('GET', url)
  File "/Library/Python/2.7/site-packages/gdata/auth.py", line 943, in GetAuthHeader
    sig = encodestring(self.rsa_key.hashAndSign(data).tostring()).rstrip()
AttributeError: 'bytearray' object has no attribute 'tostring'

The output of hashAndSign is a bytearray (for me it is anyway, is it not for the author?), which doesn't have a tostring method, at least, it doesn't in python 2.7.1, which INSTALL.txt claims this project supports. Actually, I can't find any version of python where bytearray has a tostring method. Why not just use str(self.rsa_key.hashAndSign(data)) instead? I believe this bug was introduced by commit 3c85d330c55dd1c758515b9c0a69cdf7f11c2728.