ampledata / kiss

A pure-Python implementation of the KISS Protocol for communicating with serial TNC devices for use with Amateur Radio.
Other
84 stars 35 forks source link

Should it work with Python 3 ? or: dict object has no attribute 'replace' #12

Closed Humphreybas closed 7 years ago

Humphreybas commented 8 years ago

Hi, In your introduction I can't find the compatibility with python 3. Should it work? I tried it out but got an error, I am not sure though if the error is related at all:

Python 3.4.3 (default, Jul 28 2015, 18:20:59) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import kiss
>>> k = kiss.KISS('/dev/ttyACM0', 1200)
2015-10-20 17:21:04,634 INFO kiss.classes.__init__:50 - Using interface_mode=serial
>>> k.start()
2015-10-20 17:21:07,194 DEBUG kiss.classes.start:74 - kwargs={}
>>> frame = {'text':'test'}
>>> k.write(frame)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/kiss/classes.py", line 221, in write
    kiss.util.escape_special_codes(frame),
  File "/usr/local/lib/python3.4/dist-packages/kiss/util.py", line 23, in escape_special_codes
    return raw_codes.replace(
AttributeError: 'dict' object has no attribute 'replace'
ve7mjc commented 8 years ago

I find it installs without complaint via package manager pip3 into Python3 lib location but does not work with at least Python 3.4 I am working with. If it does not work with Python3 it should be blocked from the pip3 repository if this is at all possible. I will take a crack at fixing the code if I get a chance but not sure how to maintain a codebase which can happily run on 2.x and 3.x without splitting.

I am getting the following exceptions which are typical Python 2->3 migration issues:

TypeError: Type str doesn't support the buffer API
Exception ignored in: <bound method KISS.__del__ of <kiss.classes.KISS object at 0xb730628c>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/kiss/classes.py", line 62, in __del__
AttributeError: 'socket' object has no attribute 'isOpen'
schmandt commented 7 years ago

@Humphreybas Same error is present when running on Python 2.7

Enrico204 commented 7 years ago

@schmandt @ve7mjc I've made a PR #16 for that - it's not related to python 2-3 compatibility

Humphreybas commented 7 years ago

Ok thanks