code: def _matching_string(matched, string):
          
          if string is None:
              return string
          if IS_PY2:
              # pylint: disable=undefined-variable
              if isinstance(matched, text_type):
                  return text_type(string)
          else:
              if isinstance(matched, bytes) and isinstance(string, str):
                  return string.encode(locale.getpreferredencoding(False))
          return string
docs: Return the string as byte or unicode depending
          on the type of matched, assuming string is an ASCII string.