diff --git a/cassandra/query.py b/cassandra/query.py index 1b0a56d4..c159e787 100644 --- a/cassandra/query.py +++ b/cassandra/query.py @@ -500,13 +500,13 @@ class BoundStatement(Statement): try: self.values.append(col_type.serialize(value, proto_version)) - except (TypeError, struct.error): + except (TypeError, struct.error) as exc: col_name = col_spec[2] expected_type = col_type actual_type = type(value) message = ('Received an argument of invalid type for column "%s". ' - 'Expected: %s, Got: %s' % (col_name, expected_type, actual_type)) + 'Expected: %s, Got: %s; (%s)' % (col_name, expected_type, actual_type, exc)) raise TypeError(message) return self diff --git a/tests/integration/standard/test_types.py b/tests/integration/standard/test_types.py index b0a47c06..b10f3e6b 100644 --- a/tests/integration/standard/test_types.py +++ b/tests/integration/standard/test_types.py @@ -700,10 +700,10 @@ class TypeTests(unittest.TestCase): self.assertEquals((None, None, None, None), s.execute(read)[0].t) # also test empty strings where compatible - s.execute(insert, [('', None, None, '')]) + s.execute(insert, [('', None, None, b'')]) result = s.execute("SELECT * FROM mytable WHERE k=0") - self.assertEquals(('', None, None, ''), result[0].t) - self.assertEquals(('', None, None, ''), s.execute(read)[0].t) + self.assertEquals(('', None, None, b''), result[0].t) + self.assertEquals(('', None, None, b''), s.execute(read)[0].t) c.shutdown()