z4r / python-rtkit

Python Api for Request Tracker's REST interface
http://z4r.github.com/python-rtkit/
Other
68 stars 44 forks source link

Fix import on Python 3 #62

Open tobiasge opened 5 years ago

tobiasge commented 5 years ago

This changes fixes the import for cStringIO and ifilterfalse as intended by pull request #60. In this old pull request the import for ifilterfalse is tried in the wrong direction for Python 2 and 3.

andreyyudin commented 5 years ago

This would be a useful fix for us as well.

andreyyudin commented 5 years ago

Another issue has popped up and I have been wondering if you have it as well since you are adding support to Python 3:

  File "lib/python3.7/site-packages/rtkit/authenticators.py", line 127, in _login
    urllib2.Request(self.url, urlencode(data))
  File "lib/python3.7/urllib/request.py", line 523, in open
    req = meth(req)
  File "lib/python3.7/urllib/request.py", line 1247, in do_request_
    raise TypeError(msg)
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

This can be solved by changing urllib2.Request(self.url, urlencode(data))

to urllib2.Request(self.url, urlencode(data).encode('utf-8'))

andreyyudin commented 5 years ago

Oh and there is also a problem with unicode checks in rtkit/forms.py that can be solved by doing a check on Python version.

(perhaps, I should just make a pull request once I get rtkit working)