diff options
author | Helmut Grohne <helmut@subdivi.de> | 2012-06-29 07:38:57 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2012-06-29 19:18:39 +0200 |
commit | d43d3d8947964392644b84ec1bce76c6f4193bea (patch) | |
tree | cfa2eae5ea7073396933883ad852656fdfff8163 /wsgitools/internal.py | |
parent | dd015aa622b25f8638ab0a13b5d75004d16004c8 (diff) | |
download | wsgitools-d43d3d8947964392644b84ec1bce76c6f4193bea.tar.gz |
scgi.asynchronous: move {en,de}coding to internal module
Diffstat (limited to 'wsgitools/internal.py')
-rw-r--r-- | wsgitools/internal.py | 14 |
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 |