summaryrefslogtreecommitdiff
path: root/wsgitools/internal.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/internal.py')
-rw-r--r--wsgitools/internal.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/wsgitools/internal.py b/wsgitools/internal.py
new file mode 100644
index 0000000..c392b6a
--- /dev/null
+++ b/wsgitools/internal.py
@@ -0,0 +1,14 @@
+if bytes is str:
+ def bytes2str(bstr):
+ assert isinstance(bstr, bytes)
+ return bstr
+ def str2bytes(sstr):
+ assert isinstance(sstr, str)
+ return sstr
+else:
+ def bytes2str(bstr):
+ assert isinstance(bstr, bytes)
+ return bstr.decode("iso-8859-1") # always successful
+ def str2bytes(sstr):
+ assert isinstance(sstr, str)
+ return sstr.encode("iso-8859-1") # might fail, but spec says it doesn't