Patchwork D5951: py3: port tinyproxy.py to work with Python 3

login
register
mail settings
Submitter phabricator
Date Feb. 16, 2019, 3:34 a.m.
Message ID <07dc5866ad887c20428f449808436dca@localhost.localdomain>
Download mbox | patch
Permalink /patch/38781/
State Not Applicable
Headers show

Comments

phabricator - Feb. 16, 2019, 3:34 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG97e2442a4595: py3: port tinyproxy.py to work with Python 3 (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5951?vs=14054&id=14119

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

AFFECTED FILES
  tests/tinyproxy.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -20,7 +20,10 @@ 
 import socket
 import sys
 
-from mercurial import util
+from mercurial import (
+    pycompat,
+    util,
+)
 
 httpserver = util.httpserver
 socketserver = util.socketserver
@@ -77,10 +80,11 @@ 
         try:
             if self._connect_to(self.path, soc):
                 self.log_request(200)
-                self.wfile.write(self.protocol_version +
-                                 " 200 Connection established\r\n")
-                self.wfile.write("Proxy-agent: %s\r\n" % self.version_string())
-                self.wfile.write("\r\n")
+                self.wfile.write(pycompat.bytestr(self.protocol_version) +
+                                 b" 200 Connection established\r\n")
+                self.wfile.write(b"Proxy-agent: %s\r\n" %
+                                 pycompat.bytestr(self.version_string()))
+                self.wfile.write(b"\r\n")
                 self._read_write(soc, 300)
         finally:
             print("\t" "bye")
@@ -97,15 +101,17 @@ 
         try:
             if self._connect_to(netloc, soc):
                 self.log_request()
-                soc.send("%s %s %s\r\n" % (
-                    self.command,
-                    urlreq.urlunparse(('', '', path, params, query, '')),
-                    self.request_version))
+                url = urlreq.urlunparse(('', '', path, params, query, ''))
+                soc.send(b"%s %s %s\r\n" % (
+                    pycompat.bytestr(self.command),
+                    pycompat.bytestr(url),
+                    pycompat.bytestr(self.request_version)))
                 self.headers['Connection'] = 'close'
                 del self.headers['Proxy-Connection']
-                for key_val in self.headers.items():
-                    soc.send("%s: %s\r\n" % key_val)
-                soc.send("\r\n")
+                for key, val in self.headers.items():
+                    soc.send(b"%s: %s\r\n" % (pycompat.bytestr(key),
+                                              pycompat.bytestr(val)))
+                soc.send(b"\r\n")
                 self._read_write(soc)
         finally:
             print("\t" "bye")