Patchwork D296: extensions: if on py3 and propname is a bytestr, decode as ascii

login
register
mail settings
Submitter phabricator
Date Aug. 9, 2017, 2:24 p.m.
Message ID <differential-rev-PHID-DREV-hlbyj52bnk6q7cxerkvl-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/22794/
State Superseded
Headers show

Comments

phabricator - Aug. 9, 2017, 2:24 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Property names are unicodes on Python 3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D296

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Aug. 9, 2017, 3:17 p.m.
yuja added inline comments.

INLINE COMMENTS

> extensions.py:388
> +    if pycompat.ispy3 and isinstance(propname, bytes):
> +        propname = propname.decode('ascii')
>      assert callable(wrapper)

`pycompat.sysstr()` ?

> extensions.py:401
>          raise AttributeError(
>              _("type '%s' has no property '%s'") % (cls, propname))
>  

Perhaps this shouldn't be bytes. Needs `r''` and drop `_()`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D296

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Aug. 11, 2017, 7:52 p.m.
durin42 added inline comments.

INLINE COMMENTS

> yuja wrote in extensions.py:401
> Perhaps this shouldn't be bytes. Needs `r''` and drop `_()`.

Done in a followup change.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D296

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Aug. 12, 2017, 10:21 a.m.
yuja added inline comments.

INLINE COMMENTS

> yuja wrote in extensions.py:388
> `pycompat.sysstr()` ?

The "if" shouldn't be necessary. That's what `sysstr()` is for.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D296

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Aug. 15, 2017, 8:20 p.m.
durin42 added a comment.


  Take another look?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D296

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -384,6 +384,8 @@ 
 
     These can't be wrapped using the normal wrapfunction.
     """
+    if pycompat.ispy3 and isinstance(propname, bytes):
+        propname = propname.decode('ascii')
     assert callable(wrapper)
     for currcls in cls.__mro__:
         if propname in currcls.__dict__: