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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

dsp (David Soria Parra)
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

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__:



To: durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

dsp (David Soria Parra)
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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

D296: extensions: if on py3 and propname is a bytestr, convert to sysstr

dsp (David Soria Parra)
In reply to this post by dsp (David Soria Parra)
durin42 updated this revision to Diff 799.
durin42 marked 2 inline comments as done.
durin42 retitled this revision from "extensions: if on py3 and propname is a bytestr, decode as ascii" to "extensions: if on py3 and propname is a bytestr, convert to sysstr".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D296?vs=679&id=799

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

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

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 = pycompat.sysstr(propname)
     assert callable(wrapper)
     for currcls in cls.__mro__:
         if propname in currcls.__dict__:



To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

D296: extensions: if on py3 and propname is a bytestr, convert to sysstr

dsp (David Soria Parra)
In reply to this post by dsp (David Soria Parra)
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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

D296: extensions: if on py3 and propname is a bytestr, convert to sysstr

dsp (David Soria Parra)
In reply to this post by dsp (David Soria Parra)
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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

D296: extensions: if on py3 and propname is a bytestr, convert to sysstr

dsp (David Soria Parra)
In reply to this post by dsp (David Soria Parra)
durin42 updated this revision to Diff 945.
durin42 marked 2 inline comments as done.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D296?vs=799&id=945

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

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

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



To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

D296: extensions: if on py3 and propname is a bytestr, convert to sysstr

dsp (David Soria Parra)
In reply to this post by dsp (David Soria Parra)
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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

D296: extensions: if on py3 and propname is a bytestr, convert to sysstr

dsp (David Soria Parra)
In reply to this post by dsp (David Soria Parra)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG38a3767975a7: extensions: if on py3 and propname is a bytestr, convert to sysstr (authored by durin42).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D296?vs=945&id=968

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

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

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



To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Loading...