diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -257,8 +257,10 @@ def setup(self): self.connection = self.request - self.rfile = socket._fileobject(self.request, "rb", self.rbufsize) - self.wfile = socket._fileobject(self.request, "wb", self.wbufsize) + fo = getattr(socket, '_fileobject', + lambda s, mode, bufsize: s.makefile(mode, bufsize)) + self.rfile = fo(self.request, r"rb", self.rbufsize) + self.wfile = fo(self.request, r"wb", self.wbufsize) try: import threading