mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 21:43: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:
|
if response_substring:
|
||||||
self.failUnlessIn(response_substring, res.value.response, which)
|
self.failUnlessIn(response_substring, res.value.response, which)
|
||||||
else:
|
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))
|
(which, expected_failure, res))
|
||||||
|
|
||||||
def shouldFail2(self, expected_failure, which, substring,
|
def shouldFail2(self, expected_failure, which, substring,
|
||||||
@ -642,7 +642,7 @@ class WebMixin(TimezoneMixin):
|
|||||||
res.trap(expected_failure)
|
res.trap(expected_failure)
|
||||||
if substring:
|
if substring:
|
||||||
self.failUnlessIn(substring, str(res),
|
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),
|
(substring, str(res),
|
||||||
getattr(res.value, "response", ""),
|
getattr(res.value, "response", ""),
|
||||||
which))
|
which))
|
||||||
@ -651,11 +651,11 @@ class WebMixin(TimezoneMixin):
|
|||||||
if isinstance(response, bytes):
|
if isinstance(response, bytes):
|
||||||
response = str(response, "utf-8")
|
response = str(response, "utf-8")
|
||||||
self.failUnlessIn(response_substring, response,
|
self.failUnlessIn(response_substring, response,
|
||||||
"'%s' not in '%s' for test '%s'" % \
|
"%r not in %r for test %r" % \
|
||||||
(response_substring, res.value.response,
|
(response_substring, res.value.response,
|
||||||
which))
|
which))
|
||||||
else:
|
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))
|
(which, expected_failure, res))
|
||||||
d.addBoth(done)
|
d.addBoth(done)
|
||||||
return d
|
return d
|
||||||
|
@ -705,7 +705,7 @@ class DirectoryAsHTML(Element):
|
|||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
def title(self, req, tag):
|
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]
|
header = ["Tahoe-LAFS - Directory SI=%s" % si_s]
|
||||||
if self.node.is_unknown():
|
if self.node.is_unknown():
|
||||||
header.append(" (unknown)")
|
header.append(" (unknown)")
|
||||||
@ -719,7 +719,7 @@ class DirectoryAsHTML(Element):
|
|||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
def header(self, req, tag):
|
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")]
|
header = ["Tahoe-LAFS Directory SI=", tags.span(si_s, class_="data-chars")]
|
||||||
if self.node.is_unknown():
|
if self.node.is_unknown():
|
||||||
header.append(" (unknown)")
|
header.append(" (unknown)")
|
||||||
@ -1077,13 +1077,13 @@ class RenameForm(Element, object):
|
|||||||
|
|
||||||
@renderer
|
@renderer
|
||||||
def title(self, req, tag):
|
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
|
@renderer
|
||||||
def header(self, req, tag):
|
def header(self, req, tag):
|
||||||
header = [
|
header = [
|
||||||
"Rename "
|
"Rename "
|
||||||
"in directory SI=%s" % abbreviated_dirnode(self.original),
|
"in directory SI=%s" % unicode(abbreviated_dirnode(self.original), "ascii"),
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.original.is_readonly():
|
if self.original.is_readonly():
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from past.builtins import unicode
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from urllib.parse import quote as urlquote
|
from urllib.parse import quote as urlquote
|
||||||
@ -46,7 +47,7 @@ class MoreInfoElement(Element):
|
|||||||
|
|
||||||
def abbrev(self, storage_index_or_none):
|
def abbrev(self, storage_index_or_none):
|
||||||
if 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"
|
return "LIT file"
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
@ -185,10 +185,10 @@ class FileHandler(resource.Resource, object):
|
|||||||
node = self.client.create_node_from_uri(name)
|
node = self.client.create_node_from_uri(name)
|
||||||
except (TypeError, AssertionError):
|
except (TypeError, AssertionError):
|
||||||
# I think this can no longer be reached
|
# 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)
|
% name)
|
||||||
if not IFileNode.providedBy(node):
|
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)
|
return filenode.FileNodeDownloadHandler(self.client, node)
|
||||||
|
|
||||||
@render_exception
|
@render_exception
|
||||||
|
Loading…
Reference in New Issue
Block a user