diff --git a/jc/parsers/csv_s.py b/jc/parsers/csv_s.py index acde6825..eecb7de3 100644 --- a/jc/parsers/csv_s.py +++ b/jc/parsers/csv_s.py @@ -48,7 +48,7 @@ from jc.exceptions import ParseError class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.0' + version = '1.1' description = 'CSV file streaming parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -95,8 +95,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): Iterator object """ - if not quiet: - jc.utils.compatibility(__name__, info.compatible) + if not quiet: jc.utils.compatibility(__name__, info.compatible) + if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)): + raise TypeError("Input data must be a non-string iterable object.") # convert data to an iterable in case a sequence like a list is used as input. # this allows the exhaustion of the input so we don't double-process later. diff --git a/tests/test_csv_s.py b/tests/test_csv_s.py index 4de2aec6..5a9707ce 100644 --- a/tests/test_csv_s.py +++ b/tests/test_csv_s.py @@ -74,7 +74,7 @@ class MyTests(unittest.TestCase): """ Test CSV parser with no data """ - self.assertEqual(list(jc.parsers.csv_s.parse('', quiet=True)), []) + self.assertEqual(list(jc.parsers.csv_s.parse([], quiet=True)), []) def test_csv_unparsable(self): """