warner / python-ed25519

Python bindings to the Ed25519 public-key signature system
Other
164 stars 38 forks source link

pypy3 compatibility #10

Closed miki725 closed 9 years ago

miki725 commented 9 years ago

There was an issue in from_ascii which when trying to decode base64 on unicode data caused:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import ed25519
  File "/Users/miki725/.virtualenvs/pypy3ed25519/site-packages/ed25519/__init__.py", line 1, in <module>
    from .keys import (BadSignatureError, BadPrefixError,
  File "/Users/miki725/.virtualenvs/pypy3ed25519/site-packages/ed25519/keys.py", line 191, in <module>
    selftest()
  File "/Users/miki725/.virtualenvs/pypy3ed25519/site-packages/ed25519/keys.py", line 183, in selftest
    prefix="priv0-", encoding="base64")
  File "/Users/miki725/.virtualenvs/pypy3ed25519/site-packages/ed25519/keys.py", line 82, in __init__
    sk_s = from_ascii(sk_s, encoding=encoding)
  File "/Users/miki725/.virtualenvs/pypy3ed25519/site-packages/ed25519/keys.py", line 64, in from_ascii
    s_bytes = base64.b64decode(s_ascii)
  File "/usr/local/Cellar/pypy3/2.4.0/libexec/lib-python/3/base64.py", line 83, in b64decode
    raise TypeError("expected bytes, not %s" % s.__class__.__name__)
TypeError: expected bytes, not str

https://github.com/warner/python-ed25519/commit/b7f418d6d5346cf9e87e3f9182e4b53252b834a3 addresses that.

also this PR includes flake8 fixes in https://github.com/warner/python-ed25519/commit/3c6d4f8656263c226e2058a6d58c6ad491d4f963 (using auto-formatter). If you prefer to merge without flake8, let me know and can submit separate PR fixing flake8.

warner commented 9 years ago

Oh, good catch!

Yeah, could you file a separate PR for the flake8 changes? Also, versioneer.py is copied from upstream (https://github.com/warner/python-versioneer), so the new PR should probably omit changes to that file, and we should add a Versioneer issue to get it fully flake8-clean (I thought it was already, but maybe I'm testing with an old version of flake8).

thanks!

miki725 commented 9 years ago

ok. removed flake8 commit. Ill submit another PR with those changes and will omit them from versioneer.py. thanks

warner commented 9 years ago

Sorry that took me a while to land: I just now noticed that this PR only had the pypy3 changes and not the versioneer.py ones too. I updated the tests to be pypy3-compatible too. Thanks!

miki725 commented 9 years ago

@warner no problem. thanks for merging!