def no_4byte_params(f):
 def wrapper(*args, **kwargs):
  def _is_match(some_str):
   return (isinstance(some_str, six.text_type) and (REGEX_4BYTE_UNICODE.findall(some_str) != []))
  def _check_dict(data_dict):
   for (key, value) in six.iteritems(data_dict):
    if isinstance(value, dict):
     _check_dict(value)
    else:
     if _is_match(key):
      msg = _("Property names can't contain 4 byte unicode.")
      raise exception.Invalid(msg)
     if _is_match(value):
      msg = (_("%s can't contain 4 byte unicode characters.") % key.title())
      raise exception.Invalid(msg)
  for data_dict in [arg for arg in args if isinstance(arg, dict)]:
   _check_dict(data_dict)
  for arg in args:
   if _is_match(arg):
    msg = _("Param values can't contain 4 byte unicode.")
    raise exception.Invalid(msg)
  _check_dict(kwargs)
  return f(*args, **kwargs)
 return wrapper

def no_4byte_params ( f ) : def wrapper ( * args , ** kwargs ) : def _is_match ( some_str ) : return ( isinstance ( some_str , six . text_type ) and ( REGEX_4BYTE_UNICODE . findall ( some_str ) != [ ] ) ) def _check_dict ( data_dict ) : for ( key , value ) in six . iteritems ( data_dict ) : if isinstance ( value , dict ) : _check_dict ( value ) else : if _is_match ( key ) : msg = _ ( "Property names can't contain 4 byte unicode." ) raise exception . Invalid ( msg ) if _is_match ( value ) : msg = ( _ ( "%s can't contain 4 byte unicode characters." ) % key . title ( ) ) raise exception . Invalid ( msg ) for data_dict in [ arg for arg in args if isinstance ( arg , dict ) ] : _check_dict ( data_dict ) for arg in args : if _is_match ( arg ) : msg = _ ( "Param values can't contain 4 byte unicode." ) raise exception . Invalid ( msg ) _check_dict ( kwargs ) return f ( * args , ** kwargs ) return wrapper
checks that no 4 byte unicode characters are allowed in dicts keys/values and strings parameters .