( )⚙ D887 httppeer: use native strings for headers

This is an archive of the discontinued Mercurial Phabricator instance.

httppeer: use native strings for headers
ClosedPublic

Authored by durin42 on Oct 1 2017, 12:43 PM.

Details

Summary

On Python 3, we need to use unicodes, rather than bytes. This lets
test-pull.t get a lot further along.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

durin42 created this revision.Oct 1 2017, 12:43 PM
yuja requested changes to this revision.Oct 2 2017, 11:52 AM
yuja added a subscriber: yuja.
yuja added inline comments.
mercurial/httppeer.py
233

Appears that encodevalueinheaders() takes bytes.

I don't know which would be better to pass unicodes around or convert them
at one place.

240

Perhaps this should be handled in urlencode() because it converts the output
from str to bytes.

This revision now requires changes to proceed.Oct 2 2017, 11:52 AM
durin42 marked 2 inline comments as done.Oct 14 2017, 2:52 AM
durin42 updated this revision to Diff 2720.
durin42 added inline comments.Oct 14 2017, 2:52 AM
mercurial/httppeer.py
233

I'm going to go ahead and not mess with this until I hit some test coverage for it. I think we should probably just leave encodevalueinheaders() as bytes-in but make it native-str-out, but we'll see when we get there.

240

Turns out urlencode already copes with bytes input even on Python 3. A small victory.

yuja added inline comments.Oct 14 2017, 7:37 AM
mercurial/httppeer.py
240

Nice. So we have to concatenate bytes url and bytes qs, then covert the result to unicode.

yuja requested changes to this revision.Oct 14 2017, 7:38 AM
This revision now requires changes to proceed.Oct 14 2017, 7:38 AM
durin42 updated this revision to Diff 2737.Oct 14 2017, 10:49 AM
durin42 marked an inline comment as done.Oct 14 2017, 4:17 PM

Good catch. I've now got things wired up so that (after another ~17 patches after this) some basic wireproto stuff is starting to work!

There's a templater bug I can't figure out, which I'll point out when the requisite patches to get that far land.

indygreg accepted this revision.Oct 14 2017, 4:52 PM
This revision was automatically updated to reflect the committed changes.