D2472: pycompat: prevent encoding or decoding values if not required

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sat Mar 3 17:38:40 UTC 2018


durin42 added a comment.


  In https://phab.mercurial-scm.org/D2472#40379, @indygreg wrote:
  
  > I agree with @yuja here. I think we should strive to convert URLs to bytes (like most other internal types). Although I do realize that lots of stdlib code has... expectations. Is there a particular test failure you are tracking down with this fix? I've kind of got a lot of the wire protocol code paged in right now. I could potentially offer some advice.
  
  
  test-http-bundle1.t failures. I think this current patch is probably the "least bad" option (barring getting pytype working, which I think would let us try and constrain some types in more principled ways) since some of these URL-relevant functions are called by both hg and urllib guts. The former wants to use bytes, and the latter can only use unicodes.
  
  I've poked at this on and off a few times and something like this fix is all I've come up with. I'm not happy about it either.
  
  The other option is probably to always treat URLs as unicodes, though that seems like it'll probably come with its own bag of hurt throughout the codebase.

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list