From d43d3d8947964392644b84ec1bce76c6f4193bea Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Fri, 29 Jun 2012 07:38:57 +0200 Subject: scgi.asynchronous: move {en,de}coding to internal module --- wsgitools/internal.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 wsgitools/internal.py (limited to 'wsgitools/internal.py') 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 -- cgit v1.2.3