jssimporter / python-jss

python-jss is deprecated. Please see the wiki for alternatives.
GNU General Public License v3.0
102 stars 41 forks source link

"errorMessage": "__str__ returned non-string (type bytes)" when printing ComputerGroup object #97

Closed rodgerramjet26 closed 4 years ago

rodgerramjet26 commented 4 years ago

When trying to print a computer group object I got the error: "errorMessage": "__str__ returned non-string (type bytes)"

As per this comment on https://stackoverflow.com/questions/15304229/convert-python-elementtree-to-string:

In Python 3, encoding='utf8' returns a bytestring instead of a string. I recommend using tostring(xml, encoding="unicode") instead. – Stevoisiak Feb 7 '18 at 19:18

So I believe you need to change line 159 in tools.py from: return ElementTree.tostring(pretty_data, encoding='UTF-8') to return ElementTree.tostring(pretty_data, encoding='unicode')

I did this locally and it fixed the error for me.