py3: port tinyproxy.py to work with Python 3
There were various str/bytes mismatches in the code. This caused
the proxy server to misbehave at run-time. The manifestation
was typically premature socket disconnect from the perspective
of the client.
Differential Revision: https://phab.mercurial-scm.org/D5951
from __future__ import absolute_import, print_function
import sys
from mercurial import (
pycompat,
util,
)
def main(argv):
enc = util.urlreq.quote(pycompat.sysbytes(argv[1]))
if pycompat.iswindows:
fmt = 'file:///%s'
else:
fmt = 'file://%s'
print(fmt % pycompat.sysstr(enc))
if __name__ == '__main__':
main(sys.argv)