Page MenuHomePhabricator

zeroconf: port to Python 3
ClosedPublic

Authored by indygreg on Feb 2 2019, 3:08 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Commits
rHGfa2071753dc2: zeroconf: port to Python 3
Summary

Since we're using the source transformer on Python 3, calls into
Zeroconf and return values from it are generally bytes.

But various socket functions require str on Python 3.

This commit contains enough changes to coerce test-paths.t into
passing on Python 3. I suspect there are still a handful of bugs
on Python 3. But the tests do pass.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Feb 2 2019, 3:08 PM
yuja added a subscriber: yuja.Feb 2 2019, 9:36 PM
    1. advertise to browsers svc = Zeroconf.ServiceInfo('_http._tcp.local.',
  • name + '._http._tcp.local.',

+ pycompat.bytestr(name + r'._http._tcp.local.'),

server = host,
port = port,
  • properties = {'description': desc,
  • 'path': "/" + path},

+ properties = {
+ 'description': pycompat.bytestr(desc),
+ 'path': pycompat.bytestr(r"/" + path)},

                           address = localip, weight = 0, priority = 0)
server.registerService(svc)
# advertise to Mercurial clients
svc = Zeroconf.ServiceInfo('_hg._tcp.local.',
  • name + '._hg._tcp.local.',

+ pycompat.bytestr(name + r'._hg._tcp.local.'),

server = host,
port = port,
  • properties = {'description': desc,
  • 'path': "/" + path},

+ properties = {
+ 'description': pycompat.bytestr(desc),
+ 'path': pycompat.bytestr(r"/" + path)},

address = localip, weight = 0, priority = 0)

I think path and desc are bytes since they come from ui.config().

pulkit updated this revision to Diff 15444.Jun 11 2019, 1:03 PM
pulkit added a subscriber: pulkit.Jun 11 2019, 1:04 PM

This patch is important for making test-paths.t pass on Python 3. Since Greg is quite busy now a days, I incorporated Yuya's feedback and updated it. The test still not pass though.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.