This is an archive of the discontinued Mercurial Phabricator instance.

util: prefer "bytesio" to "stringio"
ClosedPublic

Authored by indygreg on Mar 14 2018, 9:10 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Mar 14 2018, 9:10 PM
pulkit accepted this revision.Mar 15 2018, 12:11 PM
This revision was automatically updated to reflect the committed changes.