Patchwork [1,of,2] py3: add b'' to a few strings in pycompat

login
register
mail settings
Submitter Matt Harbison
Date Sept. 13, 2018, 11:48 p.m.
Message ID <d87ed52203984e979551.1536882498@Envy>
Download mbox | patch
Permalink /patch/34635/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 13, 2018, 11:48 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1536813542 14400
#      Thu Sep 13 00:39:02 2018 -0400
# Node ID d87ed52203984e979551f7dfd29f906854b5c3c0
# Parent  93acc58fb2c12c9538cb973cec1b61a308bd84dd
py3: add b'' to a few strings in pycompat

These surfaced when disabling the source transformer to debug the problems in
win32.py.
Yuya Nishihara - Sept. 14, 2018, 11:45 a.m.
On Thu, 13 Sep 2018 19:48:18 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1536813542 14400
> #      Thu Sep 13 00:39:02 2018 -0400
> # Node ID d87ed52203984e979551f7dfd29f906854b5c3c0
> # Parent  93acc58fb2c12c9538cb973cec1b61a308bd84dd
> py3: add b'' to a few strings in pycompat

For this sort of things, you can run "./contrib/byteify-strings.py -i FILE".

I didn't do that for the overall codebase yet since it would generate lots
of merge conflicts. But that's okay for pycompat.py on which nobody would
have working patches.

Patch

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -404,11 +404,11 @@  else:
     rawinput = raw_input
     getargspec = inspect.getargspec
 
-isjython = sysplatform.startswith('java')
+isjython = sysplatform.startswith(b'java')
 
-isdarwin = sysplatform == 'darwin'
-isposix = osname == 'posix'
-iswindows = osname == 'nt'
+isdarwin = sysplatform == b'darwin'
+isposix = osname == b'posix'
+iswindows = osname == b'nt'
 
 def getoptb(args, shortlist, namelist):
     return _getoptbwrapper(getopt.getopt, args, shortlist, namelist)