Patchwork [3,of,3] py3: simply use b'%d\n' to format pid in server.py

login
register
mail settings
Submitter Yuya Nishihara
Date June 1, 2017, 2:35 p.m.
Message ID <ee0119499321b4b1df8e.1496327747@mimosa>
Download mbox | patch
Permalink /patch/21127/
State Accepted
Headers show

Comments

Yuya Nishihara - June 1, 2017, 2:35 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1496325929 -32400
#      Thu Jun 01 23:05:29 2017 +0900
# Node ID ee0119499321b4b1df8e04694d82f6ca425e60df
# Parent  4bdbaa7eb382e3bff59f05342ac6a5a5fcac42ed
py3: simply use b'%d\n' to format pid in server.py

Spotted by Martin, thanks.
Augie Fackler - June 1, 2017, 2:55 p.m.
On Thu, Jun 01, 2017 at 11:35:47PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1496325929 -32400
> #      Thu Jun 01 23:05:29 2017 +0900
> # Node ID ee0119499321b4b1df8e04694d82f6ca425e60df
> # Parent  4bdbaa7eb382e3bff59f05342ac6a5a5fcac42ed
> py3: simply use b'%d\n' to format pid in server.py

Queued these, many thanks.

>
> Spotted by Martin, thanks.
>
> diff --git a/mercurial/server.py b/mercurial/server.py
> --- a/mercurial/server.py
> +++ b/mercurial/server.py
> @@ -33,7 +33,7 @@ def runservice(opts, parentfn=None, init
>              else:
>                  mode = 'wb'
>              fp = open(opts['pid_file'], mode)
> -            fp.write(str(pid).encode('latin1') + '\n')
> +            fp.write('%d\n' % pid)
>              fp.close()
>
>      if opts['daemon'] and not opts['daemon_postexec']:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/server.py b/mercurial/server.py
--- a/mercurial/server.py
+++ b/mercurial/server.py
@@ -33,7 +33,7 @@  def runservice(opts, parentfn=None, init
             else:
                 mode = 'wb'
             fp = open(opts['pid_file'], mode)
-            fp.write(str(pid).encode('latin1') + '\n')
+            fp.write('%d\n' % pid)
             fp.close()
 
     if opts['daemon'] and not opts['daemon_postexec']: