diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-06-17 19:35:21 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-06-18 22:44:01 +0200 |
commit | 4d52eaa4801df3f3169df8e58758bcccf22dc4de (patch) | |
tree | b8740a88e380a750d9d2607bb39cbc759a8d7175 /wsgitools/internal.py | |
parent | 682ce67b73453809237532a7ce2feee07f2900d5 (diff) | |
download | wsgitools-4d52eaa4801df3f3169df8e58758bcccf22dc4de.tar.gz |
drop support for Python 2.x
Diffstat (limited to 'wsgitools/internal.py')
-rw-r--r-- | wsgitools/internal.py | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/wsgitools/internal.py b/wsgitools/internal.py index c4f1da1..9bf7ded 100644 --- a/wsgitools/internal.py +++ b/wsgitools/internal.py @@ -1,19 +1,11 @@ -if bytes is str: - def bytes2str(bstr): - assert isinstance(bstr, bytes) - return bstr - def str2bytes(sstr): - assert isinstance(sstr, str) - return sstr - def textopen(filename, mode): - return open(filename, mode) -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 - def textopen(filename, mode): - # We use the same encoding as for all wsgi strings here. - return open(filename, mode, encoding="iso-8859-1") +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") |