code: def to_str(self, s):
          '''
          In py2 converts a unicode to str (bytes) using utf-8.
          -- in py3 raises an error if it's not str already.
          '''
          if s.__class__ != str:
              if not IS_PY3K:
                  s = s.encode('utf-8')
              else:
                  raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (s, s.__class__))
          return f to_str(self, s):
          '''
          In py2 converts a unicode to str (bytes) using utf-8.
          -- in py3 raises an error if it's not str already.
          '''
          if s.__class__ != str:
              if not IS_PY3K:
                  s = s.encode('utf-8')
              else:
                  raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (s, s.__class__))
          return s
docs: In py2 converts a unicode to str (bytes) using utf-8.
          -- in py3 raises an error if it's not str already.