Permalink
Browse files

Update unicode error handling. Fix intermittent csvclean test failure.

  • Loading branch information...
onyxfish committed Aug 16, 2012
1 parent 28a7aa4 commit c2f389456041ec156d1d6ce524043e46585bf9bf
Showing with 3 additions and 2 deletions.
  1. +0 −1 csvkit/cleanup.py
  2. +1 −1 csvkit/cli.py
  3. +2 −0 tests/test_utilities/test_csvclean.py
View
@@ -77,7 +77,6 @@ def checked_rows(self):
line_number = self.reader.line_num
for row in self.reader:
-
try:
if len(row) != len(self.column_names):
raise LengthMismatchError(line_number, row, len(self.column_names))
View
@@ -245,7 +245,7 @@ def handler(t, value, traceback):
# Special case handling for Unicode errors, which behave very strangely
# when cast with unicode()
if t == UnicodeDecodeError:
- sys.stderr.write('%s\n' % value)
+ sys.stderr.write('Your file is not "%s" encoded. Please specify the correct encoding with the -e flag. Use the -v flag to see the complete error.\n' % self.args.encoding)
else:
sys.stderr.write('%s\n' % unicode(value).encode('utf-8'))
@@ -2,6 +2,7 @@
from cStringIO import StringIO
import os
+from time import sleep
import unittest
from csvkit.utilities.csvclean import CSVClean
@@ -31,6 +32,7 @@ def test_simple(self):
# Cleanup
os.remove('examples/bad_err.csv')
os.remove('examples/bad_out.csv')
+ sleep(0.1)
def test_dry_run(self):
args = ['-n', 'examples/bad.csv']

0 comments on commit c2f3894

Please sign in to comment.