From 59847edf9c52f30e5ce0c39af25b606e9daaafa3 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 25 Jan 2021 10:06:05 -0500 Subject: [PATCH] More Python 3 fixes. --- src/allmydata/test/web/test_web.py | 6 +++--- src/allmydata/web/root.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/allmydata/test/web/test_web.py b/src/allmydata/test/web/test_web.py index f4fd091c5..c8749c0ba 100644 --- a/src/allmydata/test/web/test_web.py +++ b/src/allmydata/test/web/test_web.py @@ -1883,7 +1883,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi # file is SDMF or MDMF d = self.PUT("/uri?format=mdmf", self.NEWFILE_CONTENTS * 300000) - d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap)) + d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % unicode(filecap, "ascii"))) def _got_json(raw, version): data = json.loads(raw) assert "filenode" == data[0] @@ -1898,12 +1898,12 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi d.addCallback(lambda ignored: self.PUT("/uri?format=sdmf", self.NEWFILE_CONTENTS * 300000)) - d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % filecap)) + d.addCallback(lambda filecap: self.GET("/uri/%s?t=json" % unicode(filecap, "ascii"))) d.addCallback(_got_json, "SDMF") return d def test_GET_FILEURL_json_mdmf(self): - d = self.GET("/uri/%s?t=json" % urlquote(self._quux_txt_uri)) + d = self.GET("/uri/%s?t=json" % urlquote(unicode(self._quux_txt_uri, "ascii"))) d.addCallback(self.failUnlessIsQuuxJSON) return d diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index c6f272381..c0e614413 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -1,4 +1,5 @@ from future.utils import PY3 +from past.builtins import unicode import os import time @@ -97,7 +98,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 = get_arg(req, "t", "").strip() + t = unicode(get_arg(req, "t", "").strip(), "utf-8") if t == "": file_format = get_format(req, "CHK") mutable_type = get_mutable_type(file_format)