Page MenuHomePhabricator

zeroconf: port to Python 3
Needs ReviewPublic

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

Details

Reviewers
None
Group Reviewers
hg-reviewers
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
Lint Skipped
Unit
Unit Tests Skipped

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.Tue, Jun 11, 1:03 PM
pulkit added a subscriber: pulkit.Tue, Jun 11, 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.