📝 docs: link to python docs for encoding & errors parameters

We don't want to try to duplicate python docs, let's use what already
exists and just make it easier to find.
This commit is contained in:
Gina Häußge committed 2020-04-14 13:06:24 +02:00
1 parent 2fc094a563
commit e6b747aef5
2 files changed
+8 -11

No files matched your search

+3 -1
View File
@@ -35,8 +35,10 @@ needs_sphinx = '1.3'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['codeblockext', 'onlineinclude', 'sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinxcontrib.httpdomain',
'sphinx.ext.napoleon', 'sphinxcontrib.mermaid']
'sphinx.ext.napoleon', 'sphinxcontrib.mermaid', 'sphinx.ext.intersphinx']
todo_include_todos = True
intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
'python2': ('https://docs.python.org/2', None)}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
+5 -10
View File
@@ -42,15 +42,12 @@ logger = logging.getLogger(__name__)
def to_bytes(s_or_u, encoding="utf-8", errors="strict"):
# type: (Union[unicode, bytes], str, str) -> bytes
"""
Make sure ``s_or_u`` is a bytestring.
Make sure ``s_or_u`` is a byte string.
Arguments:
s_or_u (string or unicode): The value to convert
encoding (string): default 'utf-8'
errors (string): The errors argument is the same as the argument of the decode() method but supports a few more possible handlers.
As well as 'strict', 'ignore', and 'replace' (which in this case inserts a question mark instead of the unencodable character),
there is also 'xmlcharrefreplace' (inserts an XML character reference), backslashreplace (inserts a \\uNNNN escape sequence)
and namereplace (inserts a \\N{...} escape sequence).
encoding (string): encoding to use if necessary, see :meth:`python:str.encode`
errors (string): error handling to use if necessary, see :meth:`python:str.encode`
Returns:
bytes: converted bytes.
"""
@@ -73,10 +70,8 @@ def to_unicode(s_or_u, encoding="utf-8", errors="strict"):
Arguments:
s_or_u (string or unicode): The value to convert
encoding (string): default 'utf-8'
errors (string): The errors argument specifies the response when the input string can’t be converted according to the encoding’s rules.
Legal values for this argument are 'strict' (raise a UnicodeDecodeError exception), 'replace' (use U+FFFD, REPLACEMENT CHARACTER),
'ignore' (just leave the character out of the Unicode result), or 'backslashreplace' (inserts a \\xNN escape sequence).
encoding (string): encoding to use if necessary, see :meth:`python:bytes.decode`
errors (string): error handling to use if necessary, see :meth:`python:bytes.decode`
Returns:
string: converted string.
"""