code: def filename_to_str(self, filename):
          '''
          In py2 converts a unicode to str (bytes) using the file system encoding.
          -- in py3 raises an error if it's not str already.
          '''
          if filename.__class__ != str:
              if not IS_PY3K:
                  filename = filename.encode(file_system_encoding)
              else:
                  raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (filename, filename.__class__))
          return filenamf filename_to_str(self, filename):
          '''
          In py2 converts a unicode to str (bytes) using the file system encoding.
          -- in py3 raises an error if it's not str already.
          '''
          if filename.__class__ != str:
              if not IS_PY3K:
                  filename = filename.encode(file_system_encoding)
              else:
                  raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (filename, filename.__class__))
          return filename
docs: In py2 converts a unicode to str (bytes) using the file system encoding.
          -- in py3 raises an error if it's not str already.