mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Introduced force_bytes and force_str.
This is consistent with the smart_* series of functions and it's going to be used by the next commit.
This commit is contained in:
parent
f04bb6d798
commit
a120fac65a
2 changed files with 35 additions and 1 deletions
|
@ -240,14 +240,29 @@ The functions defined in this module share the following properties:
|
|||
If ``strings_only`` is ``True``, don't convert (some) non-string-like
|
||||
objects.
|
||||
|
||||
.. function:: force_bytes(s, encoding='utf-8', strings_only=False, errors='strict')
|
||||
|
||||
.. versionadded:: 1.5
|
||||
|
||||
Similar to ``smart_bytes``, except that lazy instances are resolved to
|
||||
bytestrings, rather than kept as lazy objects.
|
||||
|
||||
If ``strings_only`` is ``True``, don't convert (some) non-string-like
|
||||
objects.
|
||||
|
||||
.. function:: smart_str(s, encoding='utf-8', strings_only=False, errors='strict')
|
||||
|
||||
Alias of :func:`smart_bytes` on Python 2 and :func:`smart_text` on Python
|
||||
3. This function always returns a :class:`str`.
|
||||
3. This function returns a :class:`str` or a lazy string.
|
||||
|
||||
For instance, this is suitable for writing to :attr:`sys.stdout` on
|
||||
Python 2 and 3.
|
||||
|
||||
.. function:: force_str(s, encoding='utf-8', strings_only=False, errors='strict')
|
||||
|
||||
Alias of :func:`force_bytes` on Python 2 and :func:`force_text` on Python
|
||||
3. This function always returns a :class:`str`.
|
||||
|
||||
.. function:: iri_to_uri(iri)
|
||||
|
||||
Convert an Internationalized Resource Identifier (IRI) portion to a URI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue