summaryrefslogtreecommitdiff
path: root/requests_cache/_utils.py
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2022-06-16 15:09:04 -0500
committerJordan Cook <jordan.cook@pioneer.com>2022-06-16 16:25:58 -0500
commitb92f7645fea16c34be6ae04a1a663f8e9d56e9d9 (patch)
tree8da4886ad3e1483ff1ad0000360b67c7a592448e /requests_cache/_utils.py
parent20dcc26d7d49d2ec8ee9571161a2722bb09fed25 (diff)
downloadrequests-cache-b92f7645fea16c34be6ae04a1a663f8e9d56e9d9.tar.gz
Some additional logging and tests
Diffstat (limited to 'requests_cache/_utils.py')
-rw-r--r--requests_cache/_utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/requests_cache/_utils.py b/requests_cache/_utils.py
index 591c4c1..ea6948f 100644
--- a/requests_cache/_utils.py
+++ b/requests_cache/_utils.py
@@ -23,11 +23,15 @@ def decode(value, encoding='utf-8') -> str:
"""Decode a value from bytes, if hasn't already been.
Note: ``PreparedRequest.body`` is always encoded in utf-8.
"""
+ if not value:
+ return ''
return value.decode(encoding) if isinstance(value, bytes) else value
def encode(value, encoding='utf-8') -> bytes:
"""Encode a value to bytes, if it hasn't already been"""
+ if not value:
+ return b''
return value if isinstance(value, bytes) else str(value).encode(encoding)