[PATCH 08 of 10 py3] server: write out pid using bytes IO instead of str IO

Martin von Zweigbergk martinvonz at google.com
Wed May 31 18:56:42 EDT 2017


On Mon, May 29, 2017 at 7:32 AM, Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1496000586 14400
> #      Sun May 28 15:43:06 2017 -0400
> # Node ID c52ab13885c505252bddf459e3ef86fe1fb8f560
> # Parent  44be9a86f325e1cc3d27ce001700652ce2305178
> server: write out pid using bytes IO instead of str IO
>
> diff --git a/mercurial/server.py b/mercurial/server.py
> --- a/mercurial/server.py
> +++ b/mercurial/server.py
> @@ -29,11 +29,11 @@ def runservice(opts, parentfn=None, init
>      def writepid(pid):
>          if opts['pid_file']:
>              if appendpid:
> -                mode = 'a'
> +                mode = 'ab'
>              else:
> -                mode = 'w'
> +                mode = 'wb'
>              fp = open(opts['pid_file'], mode)
> -            fp.write(str(pid) + '\n')
> +            fp.write(str(pid).encode('latin1') + '\n')

Would the usual pattern of ("%d\n" % pid) work?

>              fp.close()
>
>      if opts['daemon'] and not opts['daemon_postexec']:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list