cherrypy update

fixes #3348
This commit is contained in:
AdeHub
2024-12-07 19:56:21 +13:00
parent 94d62430a0
commit a09e91ff8a
28 changed files with 512 additions and 108 deletions

View File

@@ -22,8 +22,9 @@ import http.client
def ntob(n, encoding='ISO-8859-1'):
"""Return the given native string as a byte string in the given
encoding.
"""Convert a native :class:`str` to a :class:`bytes` instance.
The encoding can be changed to non-ASCII optionally.
"""
assert_native(n)
# In Python 3, the native string type is unicode
@@ -31,8 +32,9 @@ def ntob(n, encoding='ISO-8859-1'):
def ntou(n, encoding='ISO-8859-1'):
"""Return the given native string as a unicode string with the given
encoding.
"""Convert a native :class:`str` to a :class:`str` instance.
This doesn't actually do anything.
"""
assert_native(n)
# In Python 3, the native string type is unicode
@@ -48,6 +50,7 @@ def tonative(n, encoding='ISO-8859-1'):
def assert_native(n):
"""Ensure that input is a native :class:`str`."""
if not isinstance(n, str):
raise TypeError('n must be a native str (got %s)' % type(n).__name__)