Skip to content

TypeError: can't use a string pattern on a bytes-like object #8

@sohimankotia

Description

@sohimankotia

Hi,

I am using python 3.4 and following code

from rejson import Client, Path

rj = Client(host='localhost', port=6379)

# Set the key `obj` to some object
obj = {
    'answer': 42,
    'arr': [None, True, 3.14],
    'truth': {
        'coord': 'out there'
    }
}
rj.jsonset('obj', Path.rootPath(), obj)

# Get something
response = rj.jsonget('obj', Path('.truth.coord'))
print (response.read().decode('utf-8'))

Value is getting inserted but while reading it is throwing following error

Traceback (most recent call last):
  File "/home/sohanvir/pyhton-workspace/rejsonDemo.py", line 16, in <module>
    response = rj.jsonget('obj', Path('.truth.coord'))
  File "/usr/local/lib/python3.4/dist-packages/rejson/client.py", line 114, in jsonget
    return self.execute_command('JSON.GET', *pieces)
  File "/usr/local/lib/python3.4/dist-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/usr/local/lib/python3.4/dist-packages/redis/client.py", line 587, in parse_response
    return self.response_callbacks[command_name](response, **options)
  File "/usr/lib/python3.4/json/decoder.py", line 343, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions