sdk报错:
TypeError: character mapping must return integer, None or unicode
Traceback (most recent call last):
File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "./download_and_upload.py", line 140, in run
self.upload(data, msg)
File "./download_and_upload.py", line 118, in upload
result = cos_api.statFile(bucket, cos_path)
File "/usr/lib/python2.6/site-packages/qcloud_cos/cos.py", line 314, in statFile
return self.__stat(bucket, path)
File "/usr/lib/python2.6/site-packages/qcloud_cos/cos.py", line 327, in __stat
sign = auth.sign_more(bucket, expired)
File "/usr/lib/python2.6/site-packages/qcloud_cos/auth.py", line 62, in sign_more
return self.app_sign(bucket, '', expired)
File "/usr/lib/python2.6/site-packages/qcloud_cos/auth.py", line 51, in app_sign
bin = hmac.new(self._secret_key, plain_text, hashlib.sha1)
File "/usr/lib64/python2.6/hmac.py", line 133, in new
return HMAC(key, msg, digestmod)
File "/usr/lib64/python2.6/hmac.py", line 72, in __init__
self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode
sdk报错: TypeError: character mapping must return integer, None or unicode
` 主要原因: python 2.6的hmac不支持unicode编码导致: http://bugs.python.org/issue5285 解决方案: 传递给api的参数进行str处理:
参考链接: http://stackoverflow.com/questions/20849805/python-hmac-typeerror-character-mapping-must-return-integer-none-or-unicode/31572219