bkjones / pyrabbit

A Python module to communicate w/ the RabbitMQ HTTP Management API
http://pyrabbit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
97 stars 86 forks source link

Decoding fails in python 3.3 #21

Closed abarton closed 10 years ago

abarton commented 10 years ago

Python 3.3.4 Pyrabbit 1.0.1 Httlib2 0.9

The following exception is thrown with an api call such as is_alive()

  ...
  File "C:\Python33\lib\site-packages\pyrabbit\api.py", line 48, in wrapper
    if self.has_admin_rights:
  File "C:\Python33\lib\site-packages\pyrabbit\api.py", line 175, in has_admin_rights
    whoami = self.get_whoami()
  File "C:\Python33\lib\site-packages\pyrabbit\api.py", line 161, in get_whoami
    whoami = self.http.do_call(path, 'GET')
  File "C:\Python33\lib\site-packages\pyrabbit\http.py", line 108, in do_call
    content = self.decode_json_content(content)
  File "C:\Python33\lib\site-packages\pyrabbit\http.py", line 75, in decode_json_content
    py_ct = json.loads(content)
  File "C:\Python33\lib\json\__init__.py", line 316, in loads
    return _default_decoder.decode(s)
  File "C:\Python33\lib\json\decoder.py", line 351, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: can't use a string pattern on a bytes-like object
bkjones commented 10 years ago

Thanks, I'll get on this in the next 2-3 weeks, if not sooner. Appreciate the feedback!

bkjones commented 10 years ago

I don't have 3.3.4, but this appears to work in head using python 3.4.1.

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyrabbit.api import Client
>>> cl = Client('localhost:55672', 'guest', 'guest')
>>> cl.is_alive()
True
>>>

If you have trouble with head, let me know. Otherwise, a new version will be released in the coming days.

abarton commented 10 years ago

It also see success when working with 3.4.1 I cannot upgrade the target environment to 3.4. Will the new version account for the error in 3.3?