Port to Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-02-22 10:31:43 -05:00
parent 0de48ba5b2
commit d0bdf1fc8a
2 changed files with 14 additions and 3 deletions

View File

@ -119,6 +119,7 @@ PORTED_MODULES = [
"allmydata.web.common",
"allmydata.web.directory",
"allmydata.web.logs",
"allmydata.web.operations",
"allmydata.webish",
]

View File

@ -1,4 +1,14 @@
from past.builtins import unicode
"""
Ported to Python 3.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import time
from hyperlink import (
@ -91,7 +101,7 @@ class OphandleTable(resource.Resource, service.Service):
"""
ophandle = get_arg(req, "ophandle").decode("utf-8")
assert ophandle
here = DecodedURL.from_text(unicode(URLPath.fromRequest(req)))
here = DecodedURL.from_text(str(URLPath.fromRequest(req)))
target = here.click(u"/").child(u"operations", ophandle)
output = get_arg(req, "output")
if output:
@ -102,7 +112,7 @@ class OphandleTable(resource.Resource, service.Service):
def getChild(self, name, req):
ophandle = name
if ophandle not in self.handles:
raise WebError("unknown/expired handle '%s'" % escape(unicode(ophandle, "utf-8")),
raise WebError("unknown/expired handle '%s'" % escape(str(ophandle, "utf-8")),
NOT_FOUND)
(monitor, renderer, when_added) = self.handles[ophandle]