summaryrefslogtreecommitdiff
path: root/wsgitools/internal.py
blob: 9bf7ded421b433eb3944d91243a7da71f1ac2d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
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

def textopen(filename, mode):
    # We use the same encoding as for all wsgi strings here.
    return open(filename, mode, encoding="iso-8859-1")