[py3] Decode stream before doing string comparisons
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 02 Oct 2019 14:18:01 +0200
changeset 3039 f14dfe93073a
parent 3038 33ad61a9f699
child 3040 12ef95c411d0
[py3] Decode stream before doing string comparisons
cubicweb_seda/dataimport.py
--- a/cubicweb_seda/dataimport.py	Wed Oct 02 14:17:57 2019 +0200
+++ b/cubicweb_seda/dataimport.py	Wed Oct 02 14:18:01 2019 +0200
@@ -133,8 +133,9 @@
 
         # also check there are the expected number of separator for each line
         stream.seek(0)
-        expected_separators = stream.readline().count(separator)
+        expected_separators = stream.readline().decode('utf-8').count(separator)
         for i, line in enumerate(stream):
+            line = line.decode('utf-8')
             if line.count(separator) != expected_separators:
                 linenum = i + 2
                 raise AssertionError('Got %s %s on line %s of %s, %s where expected'