Patchwork [2,of,2] py3: convert the mode argument of os.fdopen to unicodes (2 of 2)

login
register
mail settings
Submitter Pulkit Goyal
Date Feb. 13, 2017, 8:29 p.m.
Message ID <437f594e299aa6868278.1487017755@pulkit-goyal>
Download mbox | patch
Permalink /patch/18455/
State Accepted
Headers show

Comments

Pulkit Goyal - Feb. 13, 2017, 8:29 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1487004328 -19800
#      Mon Feb 13 22:15:28 2017 +0530
# Node ID 437f594e299aa68682783223e8fe60da230ee4a1
# Parent  c4e76e37aa693eeb31dccca18b589a01ee75c3b8
py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
Augie Fackler - Feb. 13, 2017, 10:32 p.m.
On Tue, Feb 14, 2017 at 01:59:15AM +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1487004328 -19800
> #      Mon Feb 13 22:15:28 2017 +0530
> # Node ID 437f594e299aa68682783223e8fe60da230ee4a1
> # Parent  c4e76e37aa693eeb31dccca18b589a01ee75c3b8
> py3: convert the mode argument of os.fdopen to unicodes (2 of 2)

Queued, thanks.

>
> diff -r c4e76e37aa69 -r 437f594e299a hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/hgext/convert/subversion.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -1306,7 +1306,7 @@
>              self.setexec = []
>
>          fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
> -        fp = os.fdopen(fd, 'w')
> +        fp = os.fdopen(fd, pycompat.sysstr('w'))
>          fp.write(commit.desc)
>          fp.close()
>          try:
> diff -r c4e76e37aa69 -r 437f594e299a hgext/gpg.py
> --- a/hgext/gpg.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/hgext/gpg.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -18,6 +18,7 @@
>      error,
>      match,
>      node as hgnode,
> +    pycompat,
>      util,
>  )
>
> @@ -44,11 +45,11 @@
>          try:
>              # create temporary files
>              fd, sigfile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".sig")
> -            fp = os.fdopen(fd, 'wb')
> +            fp = os.fdopen(fd, pycompat.sysstr('wb'))
>              fp.write(sig)
>              fp.close()
>              fd, datafile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".txt")
> -            fp = os.fdopen(fd, 'wb')
> +            fp = os.fdopen(fd, pycompat.sysstr('wb'))
>              fp.write(data)
>              fp.close()
>              gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify "
> diff -r c4e76e37aa69 -r 437f594e299a hgext/transplant.py
> --- a/hgext/transplant.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/hgext/transplant.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -28,6 +28,7 @@
>      merge,
>      node as nodemod,
>      patch,
> +    pycompat,
>      registrar,
>      revlog,
>      revset,
> @@ -197,7 +198,7 @@
>                      patchfile = None
>                  else:
>                      fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
> -                    fp = os.fdopen(fd, 'w')
> +                    fp = os.fdopen(fd, pycompat.sysstr('w'))
>                      gen = patch.diff(source, parent, node, opts=diffopts)
>                      for chunk in gen:
>                          fp.write(chunk)
> @@ -245,7 +246,7 @@
>          self.ui.status(_('filtering %s\n') % patchfile)
>          user, date, msg = (changelog[1], changelog[2], changelog[4])
>          fd, headerfile = tempfile.mkstemp(prefix='hg-transplant-')
> -        fp = os.fdopen(fd, 'w')
> +        fp = os.fdopen(fd, pycompat.sysstr('w'))
>          fp.write("# HG changeset patch\n")
>          fp.write("# User %s\n" % user)
>          fp.write("# Date %d %d\n" % date)
> diff -r c4e76e37aa69 -r 437f594e299a mercurial/changegroup.py
> --- a/mercurial/changegroup.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/mercurial/changegroup.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -26,6 +26,7 @@
>      error,
>      mdiff,
>      phases,
> +    pycompat,
>      util,
>  )
>
> @@ -98,7 +99,7 @@
>                  fh = open(filename, "wb", 131072)
>          else:
>              fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
> -            fh = os.fdopen(fd, "wb")
> +            fh = os.fdopen(fd, pycompat.sysstr("wb"))
>          cleanup = filename
>          for c in chunks:
>              fh.write(c)
> diff -r c4e76e37aa69 -r 437f594e299a mercurial/commands.py
> --- a/mercurial/commands.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/mercurial/commands.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -1876,7 +1876,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 c4e76e37aa69 -r 437f594e299a mercurial/pure/osutil.py
> --- a/mercurial/pure/osutil.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/mercurial/pure/osutil.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -338,7 +338,7 @@
>                  _kernel32.CloseHandle(fh)
>                  _raiseioerror(name)
>
> -            f = os.fdopen(fd, mode, bufsize)
> +            f = os.fdopen(fd, pycompat.sysstr(mode), bufsize)
>              # unfortunately, f.name is '<fdopen>' at this point -- so we store
>              # the name on this wrapper. We cannot just assign to f.name,
>              # because that attribute is read-only.
> diff -r c4e76e37aa69 -r 437f594e299a mercurial/ui.py
> --- a/mercurial/ui.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/mercurial/ui.py	Mon Feb 13 22:15:28 2017 +0530
> @@ -1038,7 +1038,7 @@
>                                        suffix=extra['suffix'], text=True,
>                                        dir=rdir)
>          try:
> -            f = os.fdopen(fd, "w")
> +            f = os.fdopen(fd, pycompat.sysstr("w"))
>              f.write(text)
>              f.close()
>
> diff -r c4e76e37aa69 -r 437f594e299a mercurial/util.py
> --- a/mercurial/util.py	Mon Feb 13 20:06:38 2017 +0530
> +++ b/mercurial/util.py	Mon Feb 13 22:15:28 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
> @@ -809,7 +809,7 @@
>      inname, outname = None, None
>      try:
>          infd, inname = tempfile.mkstemp(prefix='hg-filter-in-')
> -        fp = os.fdopen(infd, 'wb')
> +        fp = os.fdopen(infd, pycompat.sysstr('wb'))
>          fp.write(s)
>          fp.close()
>          outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Feb. 14, 2017, 12:09 a.m.
> On Feb 13, 2017, at 17:32, Augie Fackler <raf@durin42.com> wrote:
> 
> On Tue, Feb 14, 2017 at 01:59:15AM +0530, Pulkit Goyal wrote:
>> # HG changeset patch
>> # User Pulkit Goyal <7895pulkit@gmail.com>
>> # Date 1487004328 -19800
>> #      Mon Feb 13 22:15:28 2017 +0530
>> # Node ID 437f594e299aa68682783223e8fe60da230ee4a1
>> # Parent  c4e76e37aa693eeb31dccca18b589a01ee75c3b8
>> py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
> 
> Queued, thanks.

Part of this got rebased away - I'll try to do a followup to the mailing list tonight.

> 
>> 
>> diff -r c4e76e37aa69 -r 437f594e299a hgext/convert/subversion.py
>> --- a/hgext/convert/subversion.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/hgext/convert/subversion.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -1306,7 +1306,7 @@
>>             self.setexec = []
>> 
>>         fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
>> -        fp = os.fdopen(fd, 'w')
>> +        fp = os.fdopen(fd, pycompat.sysstr('w'))
>>         fp.write(commit.desc)
>>         fp.close()
>>         try:
>> diff -r c4e76e37aa69 -r 437f594e299a hgext/gpg.py
>> --- a/hgext/gpg.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/hgext/gpg.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -18,6 +18,7 @@
>>     error,
>>     match,
>>     node as hgnode,
>> +    pycompat,
>>     util,
>> )
>> 
>> @@ -44,11 +45,11 @@
>>         try:
>>             # create temporary files
>>             fd, sigfile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".sig")
>> -            fp = os.fdopen(fd, 'wb')
>> +            fp = os.fdopen(fd, pycompat.sysstr('wb'))
>>             fp.write(sig)
>>             fp.close()
>>             fd, datafile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".txt")
>> -            fp = os.fdopen(fd, 'wb')
>> +            fp = os.fdopen(fd, pycompat.sysstr('wb'))
>>             fp.write(data)
>>             fp.close()
>>             gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify "
>> diff -r c4e76e37aa69 -r 437f594e299a hgext/transplant.py
>> --- a/hgext/transplant.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/hgext/transplant.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -28,6 +28,7 @@
>>     merge,
>>     node as nodemod,
>>     patch,
>> +    pycompat,
>>     registrar,
>>     revlog,
>>     revset,
>> @@ -197,7 +198,7 @@
>>                     patchfile = None
>>                 else:
>>                     fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
>> -                    fp = os.fdopen(fd, 'w')
>> +                    fp = os.fdopen(fd, pycompat.sysstr('w'))
>>                     gen = patch.diff(source, parent, node, opts=diffopts)
>>                     for chunk in gen:
>>                         fp.write(chunk)
>> @@ -245,7 +246,7 @@
>>         self.ui.status(_('filtering %s\n') % patchfile)
>>         user, date, msg = (changelog[1], changelog[2], changelog[4])
>>         fd, headerfile = tempfile.mkstemp(prefix='hg-transplant-')
>> -        fp = os.fdopen(fd, 'w')
>> +        fp = os.fdopen(fd, pycompat.sysstr('w'))
>>         fp.write("# HG changeset patch\n")
>>         fp.write("# User %s\n" % user)
>>         fp.write("# Date %d %d\n" % date)
>> diff -r c4e76e37aa69 -r 437f594e299a mercurial/changegroup.py
>> --- a/mercurial/changegroup.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/mercurial/changegroup.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -26,6 +26,7 @@
>>     error,
>>     mdiff,
>>     phases,
>> +    pycompat,
>>     util,
>> )
>> 
>> @@ -98,7 +99,7 @@
>>                 fh = open(filename, "wb", 131072)
>>         else:
>>             fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
>> -            fh = os.fdopen(fd, "wb")
>> +            fh = os.fdopen(fd, pycompat.sysstr("wb"))
>>         cleanup = filename
>>         for c in chunks:
>>             fh.write(c)
>> diff -r c4e76e37aa69 -r 437f594e299a mercurial/commands.py
>> --- a/mercurial/commands.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/mercurial/commands.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -1876,7 +1876,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 c4e76e37aa69 -r 437f594e299a mercurial/pure/osutil.py
>> --- a/mercurial/pure/osutil.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/mercurial/pure/osutil.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -338,7 +338,7 @@
>>                 _kernel32.CloseHandle(fh)
>>                 _raiseioerror(name)
>> 
>> -            f = os.fdopen(fd, mode, bufsize)
>> +            f = os.fdopen(fd, pycompat.sysstr(mode), bufsize)
>>             # unfortunately, f.name is '<fdopen>' at this point -- so we store
>>             # the name on this wrapper. We cannot just assign to f.name,
>>             # because that attribute is read-only.
>> diff -r c4e76e37aa69 -r 437f594e299a mercurial/ui.py
>> --- a/mercurial/ui.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/mercurial/ui.py	Mon Feb 13 22:15:28 2017 +0530
>> @@ -1038,7 +1038,7 @@
>>                                       suffix=extra['suffix'], text=True,
>>                                       dir=rdir)
>>         try:
>> -            f = os.fdopen(fd, "w")
>> +            f = os.fdopen(fd, pycompat.sysstr("w"))
>>             f.write(text)
>>             f.close()
>> 
>> diff -r c4e76e37aa69 -r 437f594e299a mercurial/util.py
>> --- a/mercurial/util.py	Mon Feb 13 20:06:38 2017 +0530
>> +++ b/mercurial/util.py	Mon Feb 13 22:15:28 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
>> @@ -809,7 +809,7 @@
>>     inname, outname = None, None
>>     try:
>>         infd, inname = tempfile.mkstemp(prefix='hg-filter-in-')
>> -        fp = os.fdopen(infd, 'wb')
>> +        fp = os.fdopen(infd, pycompat.sysstr('wb'))
>>         fp.write(s)
>>         fp.close()
>>         outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r c4e76e37aa69 -r 437f594e299a hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/hgext/convert/subversion.py	Mon Feb 13 22:15:28 2017 +0530
@@ -1306,7 +1306,7 @@ 
             self.setexec = []
 
         fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
-        fp = os.fdopen(fd, 'w')
+        fp = os.fdopen(fd, pycompat.sysstr('w'))
         fp.write(commit.desc)
         fp.close()
         try:
diff -r c4e76e37aa69 -r 437f594e299a hgext/gpg.py
--- a/hgext/gpg.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/hgext/gpg.py	Mon Feb 13 22:15:28 2017 +0530
@@ -18,6 +18,7 @@ 
     error,
     match,
     node as hgnode,
+    pycompat,
     util,
 )
 
@@ -44,11 +45,11 @@ 
         try:
             # create temporary files
             fd, sigfile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".sig")
-            fp = os.fdopen(fd, 'wb')
+            fp = os.fdopen(fd, pycompat.sysstr('wb'))
             fp.write(sig)
             fp.close()
             fd, datafile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".txt")
-            fp = os.fdopen(fd, 'wb')
+            fp = os.fdopen(fd, pycompat.sysstr('wb'))
             fp.write(data)
             fp.close()
             gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify "
diff -r c4e76e37aa69 -r 437f594e299a hgext/transplant.py
--- a/hgext/transplant.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/hgext/transplant.py	Mon Feb 13 22:15:28 2017 +0530
@@ -28,6 +28,7 @@ 
     merge,
     node as nodemod,
     patch,
+    pycompat,
     registrar,
     revlog,
     revset,
@@ -197,7 +198,7 @@ 
                     patchfile = None
                 else:
                     fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
-                    fp = os.fdopen(fd, 'w')
+                    fp = os.fdopen(fd, pycompat.sysstr('w'))
                     gen = patch.diff(source, parent, node, opts=diffopts)
                     for chunk in gen:
                         fp.write(chunk)
@@ -245,7 +246,7 @@ 
         self.ui.status(_('filtering %s\n') % patchfile)
         user, date, msg = (changelog[1], changelog[2], changelog[4])
         fd, headerfile = tempfile.mkstemp(prefix='hg-transplant-')
-        fp = os.fdopen(fd, 'w')
+        fp = os.fdopen(fd, pycompat.sysstr('w'))
         fp.write("# HG changeset patch\n")
         fp.write("# User %s\n" % user)
         fp.write("# Date %d %d\n" % date)
diff -r c4e76e37aa69 -r 437f594e299a mercurial/changegroup.py
--- a/mercurial/changegroup.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/mercurial/changegroup.py	Mon Feb 13 22:15:28 2017 +0530
@@ -26,6 +26,7 @@ 
     error,
     mdiff,
     phases,
+    pycompat,
     util,
 )
 
@@ -98,7 +99,7 @@ 
                 fh = open(filename, "wb", 131072)
         else:
             fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
-            fh = os.fdopen(fd, "wb")
+            fh = os.fdopen(fd, pycompat.sysstr("wb"))
         cleanup = filename
         for c in chunks:
             fh.write(c)
diff -r c4e76e37aa69 -r 437f594e299a mercurial/commands.py
--- a/mercurial/commands.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/mercurial/commands.py	Mon Feb 13 22:15:28 2017 +0530
@@ -1876,7 +1876,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 c4e76e37aa69 -r 437f594e299a mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/mercurial/pure/osutil.py	Mon Feb 13 22:15:28 2017 +0530
@@ -338,7 +338,7 @@ 
                 _kernel32.CloseHandle(fh)
                 _raiseioerror(name)
 
-            f = os.fdopen(fd, mode, bufsize)
+            f = os.fdopen(fd, pycompat.sysstr(mode), bufsize)
             # unfortunately, f.name is '<fdopen>' at this point -- so we store
             # the name on this wrapper. We cannot just assign to f.name,
             # because that attribute is read-only.
diff -r c4e76e37aa69 -r 437f594e299a mercurial/ui.py
--- a/mercurial/ui.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/mercurial/ui.py	Mon Feb 13 22:15:28 2017 +0530
@@ -1038,7 +1038,7 @@ 
                                       suffix=extra['suffix'], text=True,
                                       dir=rdir)
         try:
-            f = os.fdopen(fd, "w")
+            f = os.fdopen(fd, pycompat.sysstr("w"))
             f.write(text)
             f.close()
 
diff -r c4e76e37aa69 -r 437f594e299a mercurial/util.py
--- a/mercurial/util.py	Mon Feb 13 20:06:38 2017 +0530
+++ b/mercurial/util.py	Mon Feb 13 22:15:28 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
@@ -809,7 +809,7 @@ 
     inname, outname = None, None
     try:
         infd, inname = tempfile.mkstemp(prefix='hg-filter-in-')
-        fp = os.fdopen(infd, 'wb')
+        fp = os.fdopen(infd, pycompat.sysstr('wb'))
         fp.write(s)
         fp.close()
         outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')