def validate_encoding_and_error_handler(setting, value, option_parser, config_parser=None, config_section=None):
 if (':' in value):
  (encoding, handler) = value.split(':')
  validate_encoding_error_handler((setting + '_error_handler'), handler, option_parser, config_parser, config_section)
  if config_parser:
   config_parser.set(config_section, (setting + '_error_handler'), handler)
  else:
   setattr(option_parser.values, (setting + '_error_handler'), handler)
 else:
  encoding = value
 validate_encoding(setting, encoding, option_parser, config_parser, config_section)
 return encoding

def validate_encoding_and_error_handler ( setting , value , option_parser , config_parser = None , config_section = None ) : if ( ':' in value ) : ( encoding , handler ) = value . split ( ':' ) validate_encoding_error_handler ( ( setting + '_error_handler' ) , handler , option_parser , config_parser , config_section ) if config_parser : config_parser . set ( config_section , ( setting + '_error_handler' ) , handler ) else : setattr ( option_parser . values , ( setting + '_error_handler' ) , handler ) else : encoding = value validate_encoding ( setting , encoding , option_parser , config_parser , config_section ) return encoding
side-effect: if an error handler is included in the value .