comparison mercurial/pure/parsers.py @ 36958:644a02f6b34f

util: prefer "bytesio" to "stringio" The io.BytesIO and io.StringIO types enforce the type of data being operated on. On Python 2, we use cStringIO.StringIO(), which is lax about mixing types. On Python 3, we actually use io.BytesIO. Ideally, we'd use io.BytesIO on Python 2. But I believe its performance is poor compared to cString.StringIO(). Anyway, we canonically define our pycompat type as "stringio." That name is misleading, especially on Python 3. This commit renames the canonical symbols to "bytesio." "stringio" is preserved as an alias for API compatibility. There are a lot of callers in the repo and I hesitate to take away the old name. I also don't feel like changing everything at this time. But at least new callers can use a "proper" name. Differential Revision: https://phab.mercurial-scm.org/D2868
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 14 Mar 2018 11:52:35 -0700
parents 531332502568
children f3d394ea17db
comparison
equal deleted inserted replaced
36957:a8d540d2628c 36958:644a02f6b34f
10 import struct 10 import struct
11 import zlib 11 import zlib
12 12
13 from ..node import nullid 13 from ..node import nullid
14 from .. import pycompat 14 from .. import pycompat
15 stringio = pycompat.stringio 15 stringio = pycompat.bytesio
16 16
17 17
18 _pack = struct.pack 18 _pack = struct.pack
19 _unpack = struct.unpack 19 _unpack = struct.unpack
20 _compress = zlib.compress 20 _compress = zlib.compress