# HG changeset patch # User Alain Leufroy # Date 1401716735 -7200 # Node ID 9c7de09a6648873cda558b1598b27ca4276f62d3 # Parent 2918ef1e31999fc51732df418d80c8a0efc42ea0 [dataimport] _create_copyfrom_buffer: raise ValueError if conversion cannot be performed If the conversion fails, there is no reason to continue execution. One should notify the error. Continuing after a misconverted data could corrupt the database. Related to #3845572 diff -r 2918ef1e3199 -r 9c7de09a6648 dataimport.py --- a/dataimport.py Mon Jun 02 13:50:15 2014 +0200 +++ b/dataimport.py Mon Jun 02 15:45:35 2014 +0200 @@ -450,10 +450,10 @@ # If a replace_sep is given, replace # the separator # (and thus avoid empty buffer) - if replace_sep is not None: - value = value.replace(_char, replace_sep) - else: - return + if replace_sep is None: + raise ValueError('conflicting separator: ' + 'you must provide the replace_sep option') + value = value.replace(_char, replace_sep) value = value.replace('\\', r'\\') if isinstance(value, unicode): value = value.encode(encoding) @@ -511,11 +511,9 @@ for types, converter in _COPYFROM_BUFFER_CONVERTERS: if isinstance(value, types): value = converter(value, **convert_opts) - if value is None: - return None break else: - return None + raise ValueError("Unsupported value type %s" % type(value)) # We push the value to the new formatted row # if the value is not None and could be converted to a string. formatted_row.append(value)