ansible/docs/docsite/rst/dev_guide/testing/sanity/no-basestring.rst
Matt Clay b4494fa547 Remove redundant "Sanity Tests »" from page title.
The docs now have multi-level breadcrumbs so including "Sanity Tests »" in the title on a sanity test page is redundant.
2019-07-26 09:07:42 -07:00

11 lines
520 B
ReStructuredText

no-basestring
=============
Do not use ``isinstance(s, basestring)`` as basestring has been removed in
Python3. You can import ``string_types``, ``binary_type``, or ``text_type``
from ``ansible.module_utils.six`` and then use ``isinstance(s, string_types)``
or ``isinstance(s, (binary_type, text_type))`` instead.
If this is part of code to convert a string to a particular type,
``ansible.module_utils._text`` contains several functions that may be even
better for you: ``to_text``, ``to_bytes``, and ``to_native``.