Ape / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
713 stars 191 forks source link

v0.3.0 gives errors regarding 'encode' #10

Closed CHgsd closed 8 years ago

CHgsd commented 8 years ago

Once the other errors are cleared, I run into errors regarding the values from the config file (This is both pip version 0.3.0 and git Master)

$ samsungctl --interactive
Traceback (most recent call last):
  File "/usr/local/bin/samsungctl", line 9, in <module>
    load_entry_point('samsungctl===0.3.0-git', 'console_scripts', 'samsungctl')()
  File "build/bdist.linux-x86_64/egg/samsungctl/__main__.py", line 101, in main
  File "build/bdist.linux-x86_64/egg/samsungctl/remote.py", line 21, in __init__
TypeError: descriptor 'encode' requires a 'str' object but received a 'unicode'

I may have incorrectly fixed this by changing this:

                          self._serialize_string(str.encode(description)) +\
                          self._serialize_string(str.encode(id)) +\
                          self._serialize_string(str.encode(name))

to this:

                          self._serialize_string(description.encode('ascii')) +\
                          self._serialize_string(id.encode("ascii")) +\
                          self._serialize_string(name.encode("ascii"))
Ape commented 8 years ago

This issue is likely caused by using an old Python version. I suspect that issues #8, #9, and #11 are, too. Please test with the latest Python version you can and see if it helps.

If you are interested in having Python 2.7 support, please submit a pull request for review. If the patch is clean and simple enough, and it doesn't affect Python 3 support in any way, I am willing to accept it. However, my recommendation is just to use Python 3.

Ape commented 8 years ago

This should be working with Python 3. Please report if it still occurs.