remove to_ascii

this is a no-op on python 3.
This commit is contained in:
Richard van der Hoff 2020-05-15 19:12:03 +01:00
parent 08fa96f030
commit 65902e08c3
3 changed files with 12 additions and 38 deletions

View file

@ -19,8 +19,7 @@ import re
import string
from collections import Iterable
import six
from six import PY2, PY3
from six import PY3
from six.moves import range
from synapse.api.errors import Codes, SynapseError
@ -68,23 +67,6 @@ def is_ascii(s):
return True
def to_ascii(s):
"""Converts a string to ascii if it is ascii, otherwise leave it alone.
If given None then will return None.
"""
if PY3:
return s
if s is None:
return None
try:
return s.encode("ascii")
except UnicodeEncodeError:
return s
def assert_valid_client_secret(client_secret):
"""Validate that a given string matches the client_secret regex defined by the spec"""
if client_secret_regex.match(client_secret) is None: