mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 13:33:09 +00:00
Fix some more unicode()-of-bytestring bugs.
This commit is contained in:
parent
05a85b0ce2
commit
eebeca31f5
@ -628,7 +628,7 @@ class WebMixin(TimezoneMixin):
|
||||
if response_substring:
|
||||
self.failUnlessIn(response_substring, res.value.response, which)
|
||||
else:
|
||||
self.fail("%s was supposed to raise %s, not get '%s'" %
|
||||
self.fail("%r was supposed to raise %s, not get %r" %
|
||||
(which, expected_failure, res))
|
||||
|
||||
def shouldFail2(self, expected_failure, which, substring,
|
||||
@ -642,7 +642,7 @@ class WebMixin(TimezoneMixin):
|
||||
res.trap(expected_failure)
|
||||
if substring:
|
||||
self.failUnlessIn(substring, str(res),
|
||||
"'%s' not in '%s' (response is '%s') for test '%s'" % \
|
||||
"%r not in %r (response is %r) for test %r" % \
|
||||
(substring, str(res),
|
||||
getattr(res.value, "response", ""),
|
||||
which))
|
||||
@ -651,11 +651,11 @@ class WebMixin(TimezoneMixin):
|
||||
if isinstance(response, bytes):
|
||||
response = str(response, "utf-8")
|
||||
self.failUnlessIn(response_substring, response,
|
||||
"'%s' not in '%s' for test '%s'" % \
|
||||
"%r not in %r for test %r" % \
|
||||
(response_substring, res.value.response,
|
||||
which))
|
||||
else:
|
||||
self.fail("%s was supposed to raise %s, not get '%s'" %
|
||||
self.fail("%r was supposed to raise %s, not get %r" %
|
||||
(which, expected_failure, res))
|
||||
d.addBoth(done)
|
||||
return d
|
||||
|
@ -705,7 +705,7 @@ class DirectoryAsHTML(Element):
|
||||
|
||||
@renderer
|
||||
def title(self, req, tag):
|
||||
si_s = abbreviated_dirnode(self.node)
|
||||
si_s = unicode(abbreviated_dirnode(self.node), "utf-8")
|
||||
header = ["Tahoe-LAFS - Directory SI=%s" % si_s]
|
||||
if self.node.is_unknown():
|
||||
header.append(" (unknown)")
|
||||
@ -719,7 +719,7 @@ class DirectoryAsHTML(Element):
|
||||
|
||||
@renderer
|
||||
def header(self, req, tag):
|
||||
si_s = abbreviated_dirnode(self.node)
|
||||
si_s = unicode(abbreviated_dirnode(self.node), "utf-8")
|
||||
header = ["Tahoe-LAFS Directory SI=", tags.span(si_s, class_="data-chars")]
|
||||
if self.node.is_unknown():
|
||||
header.append(" (unknown)")
|
||||
@ -1077,13 +1077,13 @@ class RenameForm(Element, object):
|
||||
|
||||
@renderer
|
||||
def title(self, req, tag):
|
||||
return tag("Directory SI={}".format(abbreviated_dirnode(self.original)))
|
||||
return tag("Directory SI={}".format(unicode(abbreviated_dirnode(self.original), "ascii")))
|
||||
|
||||
@renderer
|
||||
def header(self, req, tag):
|
||||
header = [
|
||||
"Rename "
|
||||
"in directory SI=%s" % abbreviated_dirnode(self.original),
|
||||
"in directory SI=%s" % unicode(abbreviated_dirnode(self.original), "ascii"),
|
||||
]
|
||||
|
||||
if self.original.is_readonly():
|
||||
|
@ -1,3 +1,4 @@
|
||||
from past.builtins import unicode
|
||||
|
||||
import os
|
||||
from urllib.parse import quote as urlquote
|
||||
@ -46,7 +47,7 @@ class MoreInfoElement(Element):
|
||||
|
||||
def abbrev(self, storage_index_or_none):
|
||||
if storage_index_or_none:
|
||||
return base32.b2a(storage_index_or_none)[:6]
|
||||
return unicode(base32.b2a(storage_index_or_none)[:6], "ascii")
|
||||
return "LIT file"
|
||||
|
||||
def get_type(self):
|
||||
|
@ -185,10 +185,10 @@ class FileHandler(resource.Resource, object):
|
||||
node = self.client.create_node_from_uri(name)
|
||||
except (TypeError, AssertionError):
|
||||
# I think this can no longer be reached
|
||||
raise WebError("'%s' is not a valid file- or directory- cap"
|
||||
raise WebError("%r is not a valid file- or directory- cap"
|
||||
% name)
|
||||
if not IFileNode.providedBy(node):
|
||||
raise WebError("'%s' is not a file-cap" % name)
|
||||
raise WebError("%r is not a file-cap" % name)
|
||||
return filenode.FileNodeDownloadHandler(self.client, node)
|
||||
|
||||
@render_exception
|
||||
|
Loading…
Reference in New Issue
Block a user