Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95081:5fdece607d46
Date: 2018-09-02 17:28 +0200
http://bitbucket.org/pypy/pypy/changeset/5fdece607d46/
Log: use utf8 iterator in _csv.reader
diff --git a/pypy/module/_csv/interp_reader.py
b/pypy/module/_csv/interp_reader.py
--- a/pypy/module/_csv/interp_reader.py
+++ b/pypy/module/_csv/interp_reader.py
@@ -1,4 +1,5 @@
from rpython.rlib.rstring import UnicodeBuilder
+from rpython.rlib.rutf8 import Utf8StringIterator
from rpython.rlib import objectmodel
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
@@ -76,9 +77,11 @@
if space.isinstance_w(w_line, space.w_bytes):
raise self.error(u"iterator should return strings, not bytes "
u"(did you open the file in text mode?")
- line = space.realunicode_w(w_line)
- for c in line:
- if c == b'\0':
+ line = space.utf8_w(w_line)
+ for c in Utf8StringIterator(line):
+ # XXX rewrite this to use c (as int) not unichr(c)
+ c = unichr(c)
+ if c == '\0':
raise self.error(u"line contains NULL byte")
if state == START_RECORD:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit