Remove str_text from fileutil.py, strformat.py and url.py

This commit is contained in:
Chris Mayo 2020-05-19 19:56:42 +01:00
parent ebcc3c4961
commit 28f4587dfa
3 changed files with 3 additions and 7 deletions

View file

@ -24,7 +24,6 @@ import tempfile
import importlib
from distutils.spawn import find_executable
from functools import lru_cache
from builtins import str as str_text
def has_module(name, without_error=True):
@ -71,7 +70,7 @@ else:
def path_safe(path):
"""Ensure path string is compatible with the platform file system encoding."""
if isinstance(path, str_text) and not os.path.supports_unicode_filenames:
if isinstance(path, str) and not os.path.supports_unicode_filenames:
path = path.encode(FSCODING, "replace").decode(FSCODING)
return path

View file

@ -37,8 +37,6 @@ import locale
import pydoc
from . import i18n
from builtins import str as str_text
def unicode_safe(s, encoding=i18n.default_encoding, errors='replace'):
"""Get unicode string without raising encoding errors. Unknown
@ -68,7 +66,7 @@ def ascii_safe(s):
@return: encoded ASCII version of s, or None if s was None
@rtype: string
"""
if isinstance(s, str_text):
if isinstance(s, str):
s = s.encode('ascii', 'ignore').decode('ascii')
return s

View file

@ -22,7 +22,6 @@ import re
import urllib.parse
import requests
from builtins import str as str_text
from . import log, LOG_CHECK
@ -173,7 +172,7 @@ def idna_encode(host):
to RFC 3490.
@raise: UnicodeError if hostname is not properly IDN encoded.
"""
if host and isinstance(host, str_text):
if host and isinstance(host, str):
try:
host.encode('ascii')
return host, False