comparison mercurial/util.py @ 36964: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 68ae7d764a65
children d683c7367989
comparison
equal deleted inserted replaced
36963:a8d540d2628c 36964:644a02f6b34f
69 queue = pycompat.queue 69 queue = pycompat.queue
70 socketserver = pycompat.socketserver 70 socketserver = pycompat.socketserver
71 stderr = pycompat.stderr 71 stderr = pycompat.stderr
72 stdin = pycompat.stdin 72 stdin = pycompat.stdin
73 stdout = pycompat.stdout 73 stdout = pycompat.stdout
74 stringio = pycompat.stringio 74 bytesio = pycompat.bytesio
75 # TODO deprecate stringio name, as it is a lie on Python 3.
76 stringio = bytesio
75 xmlrpclib = pycompat.xmlrpclib 77 xmlrpclib = pycompat.xmlrpclib
76 78
77 httpserver = urllibcompat.httpserver 79 httpserver = urllibcompat.httpserver
78 urlerr = urllibcompat.urlerr 80 urlerr = urllibcompat.urlerr
79 urlreq = urllibcompat.urlreq 81 urlreq = urllibcompat.urlreq