Patchwork [py3] pycompat: default to BytesIO instead of StringIO

login
register
mail settings
Submitter Pulkit Goyal
Date March 12, 2017, 7:27 p.m.
Message ID <047e7ee79f6a30b295bf.1489346826@pulkit-goyal>
Download mbox | patch
Permalink /patch/19214/
State Accepted
Headers show

Comments

Pulkit Goyal - March 12, 2017, 7:27 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489346714 -19800
#      Mon Mar 13 00:55:14 2017 +0530
# Node ID 047e7ee79f6a30b295bf02fa23171212848546f6
# Parent  719e64bf9ec2d7b8e86b6550a5d193b3c67944d1
pycompat: default to BytesIO instead of StringIO
Gregory Szorc - March 12, 2017, 7:29 p.m.
On Sun, Mar 12, 2017 at 12:27 PM, Pulkit Goyal <7895pulkit@gmail.com> wrote:

> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489346714 -19800
> #      Mon Mar 13 00:55:14 2017 +0530
> # Node ID 047e7ee79f6a30b295bf02fa23171212848546f6
> # Parent  719e64bf9ec2d7b8e86b6550a5d193b3c67944d1
> pycompat: default to BytesIO instead of StringIO
>
> diff -r 719e64bf9ec2 -r 047e7ee79f6a mercurial/pycompat.py
> --- a/mercurial/pycompat.py     Sun Mar 12 00:47:39 2017 -0500
> +++ b/mercurial/pycompat.py     Mon Mar 13 00:55:14 2017 +0530
> @@ -55,6 +55,7 @@
>      sysexecutable = sys.executable
>      if sysexecutable:
>          sysexecutable = os.fsencode(sysexecutable)
> +    stringio = io.BytesIO
>
>      # TODO: .buffer might not exist if std streams were replaced; we'll
> need
>      # a silly wrapper to make a bytes stream backed by a unicode one.
> @@ -180,8 +181,8 @@
>      getcwd = os.getcwd
>      sysexecutable = sys.executable
>      shlexsplit = shlex.split
> +    stringio = io.StringIO
>

Should this attempt to use cStringIO.StringIO?


>
> -stringio = io.StringIO
>  empty = _queue.Empty
>  queue = _queue.Queue
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Augie Fackler - March 12, 2017, 7:34 p.m.
On Mon, Mar 13, 2017 at 12:57:06AM +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489346714 -19800
> #      Mon Mar 13 00:55:14 2017 +0530
> # Node ID 047e7ee79f6a30b295bf02fa23171212848546f6
> # Parent  719e64bf9ec2d7b8e86b6550a5d193b3c67944d1
> pycompat: default to BytesIO instead of StringIO

Queued, thanks.

>
> diff -r 719e64bf9ec2 -r 047e7ee79f6a mercurial/pycompat.py
> --- a/mercurial/pycompat.py	Sun Mar 12 00:47:39 2017 -0500
> +++ b/mercurial/pycompat.py	Mon Mar 13 00:55:14 2017 +0530
> @@ -55,6 +55,7 @@
>      sysexecutable = sys.executable
>      if sysexecutable:
>          sysexecutable = os.fsencode(sysexecutable)
> +    stringio = io.BytesIO
>
>      # TODO: .buffer might not exist if std streams were replaced; we'll need
>      # a silly wrapper to make a bytes stream backed by a unicode one.
> @@ -180,8 +181,8 @@
>      getcwd = os.getcwd
>      sysexecutable = sys.executable
>      shlexsplit = shlex.split
> +    stringio = io.StringIO
>
> -stringio = io.StringIO
>  empty = _queue.Empty
>  queue = _queue.Queue
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r 719e64bf9ec2 -r 047e7ee79f6a mercurial/pycompat.py
--- a/mercurial/pycompat.py	Sun Mar 12 00:47:39 2017 -0500
+++ b/mercurial/pycompat.py	Mon Mar 13 00:55:14 2017 +0530
@@ -55,6 +55,7 @@ 
     sysexecutable = sys.executable
     if sysexecutable:
         sysexecutable = os.fsencode(sysexecutable)
+    stringio = io.BytesIO
 
     # TODO: .buffer might not exist if std streams were replaced; we'll need
     # a silly wrapper to make a bytes stream backed by a unicode one.
@@ -180,8 +181,8 @@ 
     getcwd = os.getcwd
     sysexecutable = sys.executable
     shlexsplit = shlex.split
+    stringio = io.StringIO
 
-stringio = io.StringIO
 empty = _queue.Empty
 queue = _queue.Queue