Patchwork py3: convert the mode argument of os.fdopen to unicodes

login
register
mail settings
Submitter Pulkit Goyal
Date Feb. 16, 2017, 12:03 p.m.
Message ID <531e506fddb37aa28751.1487246609@pulkit-goyal>
Download mbox | patch
Permalink /patch/18546/
State Accepted
Headers show

Comments

Pulkit Goyal - Feb. 16, 2017, 12:03 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1487246435 -19800
#      Thu Feb 16 17:30:35 2017 +0530
# Node ID 531e506fddb37aa28751dfdd733fd9bb9a07fc63
# Parent  1ee685defe80117cf6aafea1ede6c33c478abceb
py3: convert the mode argument of os.fdopen to unicodes

Couple of these from the earlier series got lost while rebasing. So this patch
converts them again.
Augie Fackler - Feb. 16, 2017, 5:02 p.m.
On Thu, Feb 16, 2017 at 05:33:29PM +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1487246435 -19800
> #      Thu Feb 16 17:30:35 2017 +0530
> # Node ID 531e506fddb37aa28751dfdd733fd9bb9a07fc63
> # Parent  1ee685defe80117cf6aafea1ede6c33c478abceb
> py3: convert the mode argument of os.fdopen to unicodes

Queued, thanks.

>
> Couple of these from the earlier series got lost while rebasing. So this patch
> converts them again.
>
> diff -r 1ee685defe80 -r 531e506fddb3 mercurial/debugcommands.py
> --- a/mercurial/debugcommands.py	Wed Feb 15 16:29:58 2017 -0800
> +++ b/mercurial/debugcommands.py	Thu Feb 16 17:30:35 2017 +0530
> @@ -910,7 +910,7 @@
>
>      def writetemp(contents):
>          (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
> -        f = os.fdopen(fd, "wb")
> +        f = os.fdopen(fd, pycompat.sysstr("wb"))
>          f.write(contents)
>          f.close()
>          return name
> diff -r 1ee685defe80 -r 531e506fddb3 mercurial/util.py
> --- a/mercurial/util.py	Wed Feb 15 16:29:58 2017 -0800
> +++ b/mercurial/util.py	Thu Feb 16 17:30:35 2017 +0530
> @@ -73,7 +73,7 @@
>  # destined stdout with a pipe destined stdout (e.g. pager), we want line
>  # buffering
>  if isatty(stdout):
> -    stdout = os.fdopen(stdout.fileno(), 'wb', 1)
> +    stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
>
>  if pycompat.osname == 'nt':
>      from . import windows as platform
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r 1ee685defe80 -r 531e506fddb3 mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Wed Feb 15 16:29:58 2017 -0800
+++ b/mercurial/debugcommands.py	Thu Feb 16 17:30:35 2017 +0530
@@ -910,7 +910,7 @@ 
 
     def writetemp(contents):
         (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
-        f = os.fdopen(fd, "wb")
+        f = os.fdopen(fd, pycompat.sysstr("wb"))
         f.write(contents)
         f.close()
         return name
diff -r 1ee685defe80 -r 531e506fddb3 mercurial/util.py
--- a/mercurial/util.py	Wed Feb 15 16:29:58 2017 -0800
+++ b/mercurial/util.py	Thu Feb 16 17:30:35 2017 +0530
@@ -73,7 +73,7 @@ 
 # destined stdout with a pipe destined stdout (e.g. pager), we want line
 # buffering
 if isatty(stdout):
-    stdout = os.fdopen(stdout.fileno(), 'wb', 1)
+    stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
 
 if pycompat.osname == 'nt':
     from . import windows as platform