code: def valid_domain(domain):
      "Validate a cookie domain ASCII string"
      # Using encoding on domain would confuse browsers into not sending cookies.
      # Generate UnicodeDecodeError up front if it can't store as ASCII.
      domain.encode('ascii')
      # Domains starting with periods are not RFC-valid, but this is very common
      # in existing cookies, so they should still parse with DOMAIN_AV.
      if Definitions.DOMAIN_RE.match(domain):
          return True
      return Falsf valid_domain(domain):
      "Validate a cookie domain ASCII string"
      # Using encoding on domain would confuse browsers into not sending cookies.
      # Generate UnicodeDecodeError up front if it can't store as ASCII.
      domain.encode('ascii')
      # Domains starting with periods are not RFC-valid, but this is very common
      # in existing cookies, so they should still parse with DOMAIN_AV.
      if Definitions.DOMAIN_RE.match(domain):
          return True
      return False
docs: Validate a cookie domain ASCII string