Skip to content

Can't pass a bytearray to SET #1214

@red-lithium

Description

@red-lithium

Version: redis-py 3.3.8 and redis 5.0.5

Platform: Python 3.6.8 on Ubuntu 18.04

Description: Redis strings are should be binary safe, but redis.set(key, value) doesn't accept a bytearray as a valid type. Passing a bytearray in as a value, results in the following exception:
Invalid input of type: 'bytearray'. Convert to a byte, string or number first.

I understand that this might be a limitation of Python or perhaps I've misunderstood the Redis documentation. Thanks in advance.

Example code:

#!/usr/bin/python3
import redis

redis = redis.Redis(host="localhost", port=6379, db=0)

# This will result in an exception
redis.set("my-key", bytearray(10))

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