Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Conversation

YSunLIN
Copy link

@YSunLIN YSunLIN commented Mar 4, 2018

See #86

In Python3, using str as the type of _buf causes TypeError: Can't convert 'bytes' object to str implicitly in the newest commit 0b15f4f with python-rsa.

  File ".\adb.zip\__main__.py", line 210, in <module>
  File ".\adb.zip\__main__.py", line 206, in main
  File ".\adb.zip\adb\common_cli.py", line 149, in StartCli
  File ".\adb.zip\adb\adb_commands.py", line 138, in ConnectDevice
  File ".\adb.zip\adb\adb_commands.py", line 169, in _Connect
  File ".\adb.zip\adb\adb_protocol.py", line 320, in Connect
  File ".\adb.zip\adb\sign_pythonrsa.py", line 69, in Sign
  File "E:\Python\Python3\lib\site-packages\rsa\pkcs1.py", line 272, in sign
    hash = _hash(message, hash)
  File "E:\Python\Python3\lib\site-packages\rsa\pkcs1.py", line 346, in _hash
    hasher.update(message)
  File ".\adb.zip\adb\sign_pythonrsa.py", line 29, in update
TypeError: Can't convert 'bytes' object to str implicitly

And it can be fixed below:

   # hashing algo for this.
   class _Accum(object):
     def __init__(self):
 -     self._buf = ''
 +     self._buf = b''
     def update(self, msg):
       self._buf += msg
     def digest(self):
       return self._buf

And thanks to @Myonium, the TypeError in TcpHandle can also be resolved.

@fahhem I don't know why this PR cannot be accepted. If you guys don't want to merge this branch, just close it.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 42.691% when pulling 9a0a928 on YSunLIN:master into 0b15f4f on google:master.

@coveralls
Copy link

coveralls commented Mar 4, 2018

Coverage Status

Coverage remained the same at 42.384% when pulling d26c3d5 on YSunLIN:master into ee2d54e on google:master.

@fahhem
Copy link
Contributor

fahhem commented May 31, 2018

Hmm, this seems to cause problems with the USB handle. It seems the TCPHandle needs to convert to bytes in the right place, because the signing libraries should only see binary data, not unicode.

@YSunLIN
Copy link
Author

YSunLIN commented Jun 4, 2018

@fahhem I opened the issue #86 and then made a pull request #89 to fix the problem.
I also merged the @Myonium's TcpHandle solution to which you agreed.
However, you merged #97 and ignored this PR until now.
I don't know if it is discrimination or not.

@fahhem
Copy link
Contributor

fahhem commented Jun 4, 2018

Lol, not discrimination, I just come back to this project on and off and don't necessarily remember all the things every time (nor do I go through all the issues every time).

Well, hopefully it works now for USB and tcp! If you'd like credit you can add yourself to the CONTRIBUTORS file in another PR, I'll gladly merge it since you've contributed via issues as well as code.

@fahhem fahhem closed this Jun 4, 2018
@YSunLIN
Copy link
Author

YSunLIN commented Jun 7, 2018

Thanks for your prompt reply. And I will continue contributing to this repo.

@fahhem
Copy link
Contributor

fahhem commented Jun 7, 2018

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants