Patchwork [3,of,4,py3] help: use pycompat.sysstr() to make `a in b` work

login
register
mail settings
Submitter Pulkit Goyal
Date March 12, 2017, 5:19 p.m.
Message ID <6cccbcf562c29d073d9c.1489339190@pulkit-goyal>
Download mbox | patch
Permalink /patch/19168/
State Accepted
Headers show

Comments

Pulkit Goyal - March 12, 2017, 5:19 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489338223 -19800
#      Sun Mar 12 22:33:43 2017 +0530
# Node ID 6cccbcf562c29d073d9cdf775fb07e40e32fad0b
# Parent  782455a21077bef9c13532ad8dfa69fde1e5ebfc
help: use pycompat.sysstr() to make `a in b` work

doc is unicode here, making doc bytes was an option but here we are just
evaluating an expression so I guess the other way around will be okay.
Yuya Nishihara - March 12, 2017, 5:31 p.m.
On Sun, 12 Mar 2017 22:49:50 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489338223 -19800
> #      Sun Mar 12 22:33:43 2017 +0530
> # Node ID 6cccbcf562c29d073d9cdf775fb07e40e32fad0b
> # Parent  782455a21077bef9c13532ad8dfa69fde1e5ebfc
> help: use pycompat.sysstr() to make `a in b` work
> 
> doc is unicode here, making doc bytes was an option but here we are just
> evaluating an expression so I guess the other way around will be okay.
> 
> diff -r 782455a21077 -r 6cccbcf562c2 mercurial/help.py
> --- a/mercurial/help.py	Sun Mar 12 22:27:53 2017 +0530
> +++ b/mercurial/help.py	Sun Mar 12 22:33:43 2017 +0530
> @@ -23,6 +23,7 @@
>      filemerge,
>      fileset,
>      minirst,
> +    pycompat,
>      revset,
>      templatefilters,
>      templatekw,
> @@ -109,7 +110,7 @@
>  def filtercmd(ui, cmd, kw, doc):
>      if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
>          return True
> -    if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
> +    if not ui.verbose and doc and any(pycompat.sysstr(w) in doc for w in _exclkeywords):
>          return True
>      return False

__doc__ should be converted to bytes (in local encoding) instead. Maybe we'll
need a helper something like pycompat.getdoc(func_or_class).

I've queued the other patches, thanks.

Patch

diff -r 782455a21077 -r 6cccbcf562c2 mercurial/help.py
--- a/mercurial/help.py	Sun Mar 12 22:27:53 2017 +0530
+++ b/mercurial/help.py	Sun Mar 12 22:33:43 2017 +0530
@@ -23,6 +23,7 @@ 
     filemerge,
     fileset,
     minirst,
+    pycompat,
     revset,
     templatefilters,
     templatekw,
@@ -109,7 +110,7 @@ 
 def filtercmd(ui, cmd, kw, doc):
     if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
         return True
-    if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+    if not ui.verbose and doc and any(pycompat.sysstr(w) in doc for w in _exclkeywords):
         return True
     return False