Patchwork [03,of,10] py3: use %s instead of %b to print a list

login
register
mail settings
Submitter Pulkit Goyal
Date May 4, 2017, 10:46 p.m.
Message ID <100e7fc11bf088bfa585.1493938008@pulkit-goyal>
Download mbox | patch
Permalink /patch/20443/
State Accepted
Headers show

Comments

Pulkit Goyal - May 4, 2017, 10:46 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493837589 -19800
#      Thu May 04 00:23:09 2017 +0530
# Node ID 100e7fc11bf088bfa58532680f8917bf3750599f
# Parent  b686f18461301572e82a1d85b2691d1d1d7f27b5
py3: use %s instead of %b to print a list

Here pats is a list obviously. We add u'' to make sure %s don't get converted
to %b by the transformer. r'' is not used because then \n won't be interpreted
as newline.
Yuya Nishihara - May 5, 2017, 10:16 a.m.
On Fri, 05 May 2017 04:16:48 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1493837589 -19800
> #      Thu May 04 00:23:09 2017 +0530
> # Node ID 100e7fc11bf088bfa58532680f8917bf3750599f
> # Parent  b686f18461301572e82a1d85b2691d1d1d7f27b5
> py3: use %s instead of %b to print a list
> 
> Here pats is a list obviously. We add u'' to make sure %s don't get converted
> to %b by the transformer. r'' is not used because then \n won't be interpreted
> as newline.
> 
> diff -r b686f1846130 -r 100e7fc11bf0 hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py	Wed May 03 15:41:28 2017 +0530
> +++ b/hgext/largefiles/overrides.py	Thu May 04 00:23:09 2017 +0530
> @@ -381,7 +381,7 @@
>              return r
>          m.matchfn = lfmatchfn
>  
> -        ui.debug('updated patterns: %s\n' % sorted(pats))
> +        ui.debug(u'updated patterns: %s\n' % sorted(pats))

You can't print a unicode by ui.debug(). Here we'll have to format pats
by ourselves.

Patch

diff -r b686f1846130 -r 100e7fc11bf0 hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Wed May 03 15:41:28 2017 +0530
+++ b/hgext/largefiles/overrides.py	Thu May 04 00:23:09 2017 +0530
@@ -381,7 +381,7 @@ 
             return r
         m.matchfn = lfmatchfn
 
-        ui.debug('updated patterns: %s\n' % sorted(pats))
+        ui.debug(u'updated patterns: %s\n' % sorted(pats))
         return m, pats
 
     # For hg log --patch, the match object is used in two different senses: