From 99db408a4648226616efa1cb5a458b43874609b6 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 23 Feb 2021 10:03:58 -0500 Subject: [PATCH] Port to Python 3. --- src/allmydata/util/_python3.py | 1 + src/allmydata/web/root.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 40178c6c3..d1050d079 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -121,6 +121,7 @@ PORTED_MODULES = [ "allmydata.web.logs", "allmydata.web.operations", "allmydata.web.private", + "allmydata.web.root", "allmydata.webish", ] diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 068751a61..b7dc8b5f4 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -1,5 +1,14 @@ -from future.utils import PY3 -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, PY3 +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 os import time @@ -98,7 +107,7 @@ class URIHandler(resource.Resource, object): either "PUT /uri" to create an unlinked file, or "PUT /uri?t=mkdir" to create an unlinked directory """ - t = unicode(get_arg(req, "t", "").strip(), "utf-8") + t = str(get_arg(req, "t", "").strip(), "utf-8") if t == "": file_format = get_format(req, "CHK") mutable_type = get_mutable_type(file_format) @@ -121,7 +130,7 @@ class URIHandler(resource.Resource, object): unlinked file or "POST /uri?t=mkdir" to create a new directory """ - t = unicode(get_arg(req, "t", "").strip(), "ascii") + t = str(get_arg(req, "t", "").strip(), "ascii") if t in ("", "upload"): file_format = get_format(req) mutable_type = get_mutable_type(file_format)