summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index bc312ed..9715e5d 100644
--- a/utils.py
+++ b/utils.py
@@ -9,6 +9,9 @@ if sys.version_info.major == 2:
return buf
return buf.decode("utf-8")
+ def to_bytes(buf):
+ return buf
+
class Encoded:
def __init__(self, stream):
self.stream = stream
@@ -30,3 +33,8 @@ else:
def to_unicode(buf):
return buf
+
+ def to_bytes(buf):
+ if type(buf) is bytes:
+ return buf
+ return bytes(buf, "utf-8")