djacobs / PyAPNs

Python library for interacting with the Apple Push Notification service (APNs)
http://pypi.python.org/pypi/apns/
MIT License
1.22k stars 374 forks source link

Python 3 support #177

Closed kobzar closed 7 years ago

kobzar commented 8 years ago

Have a lot of errors on python3.4 with str & byte convert. Example, when i try used Frame() or feedback_server.items() a was error

"TypeError: Can't convert 'bytes' object to str implicitly"

For second trouble i fixed it simply: apns.py

  def items(self):
        """
        A generator that yields (token_hex, fail_time) pairs retrieved from
        the APNs feedback server
        """
        buff = b'' #changed buff = '' to buff = b''

But cant fixed the same for Frame()

kobzar commented 8 years ago

Just change '/xx' to b'/xx' And all working now.

jd20 commented 7 years ago

Another Python 3 compatibility issue (tested with 3.6.0):

  File "/.../lib/python3.6/site-packages/apns.py", line 218
    except ssl.SSLError, err:
                       ^
SyntaxError: invalid syntax

Also, not sure what version of Python 3 is supported, might be good to add that somewhere to the README.md.

djacobs commented 7 years ago

This is something that is in mind, but I don't have time to follow-up right now.

ExplodingCabbage commented 7 years ago

@jd20 the code you're quoting doesn't exist any more on the master branch, but the version of the library on PyPi is out of date (see https://github.com/djacobs/PyAPNs/issues/163). The master version from GitHub should be usable on Python 3.