Skip to content

Encoder support date type #3651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions redis/_parsers/encoders.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import date

from ..exceptions import DataError


Expand All @@ -23,6 +25,8 @@ def encode(self, value):
)
elif isinstance(value, (int, float)):
value = repr(value).encode()
elif isinstance(value, date):
value = str(value).encode(self.encoding, self.encoding_errors)
elif not isinstance(value, str):
# a value we don't know how to deal with. throw an error
typename = type(value).__name__
Expand All @@ -32,6 +36,7 @@ def encode(self, value):
)
if isinstance(value, str):
value = value.encode(self.encoding, self.encoding_errors)

return value

def decode(self, value, force=False):
Expand Down