mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-07 10:56:49 +00:00
Merge pull request #1085 from tahoe-lafs/3738.failing-unicode-upload-regression-python-2
Fix bug where uploading files with Unicode filenames failed on Python 2 Fixes ticket:3738
This commit is contained in:
commit
83b4fb88f4
1
newsfragments/3738.bugfix
Normal file
1
newsfragments/3738.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix regression where uploading files with non-ASCII names failed.
|
@ -94,11 +94,17 @@ def do_http(method, url, body=b""):
|
||||
|
||||
|
||||
def format_http_success(resp):
|
||||
return "%s %s" % (resp.status, quote_output(resp.reason, quotemarks=False))
|
||||
# ensure_text() shouldn't be necessary when Python 2 is dropped.
|
||||
return quote_output(
|
||||
"%s %s" % (resp.status, six.ensure_text(resp.reason)),
|
||||
quotemarks=False)
|
||||
|
||||
def format_http_error(msg, resp):
|
||||
return "%s: %s %s\n%s" % (msg, resp.status, quote_output(resp.reason, quotemarks=False),
|
||||
quote_output(resp.read(), quotemarks=False))
|
||||
# ensure_text() shouldn't be necessary when Python 2 is dropped.
|
||||
return quote_output(
|
||||
"%s: %s %s\n%s" % (msg, resp.status, six.ensure_text(resp.reason),
|
||||
six.ensure_text(resp.read())),
|
||||
quotemarks=False)
|
||||
|
||||
def check_http_error(resp, stderr):
|
||||
if resp.status < 200 or resp.status >= 300:
|
||||
|
@ -55,6 +55,11 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:" + artonwall_arg))
|
||||
d.addCallback(lambda rc_out_err: self.assertEqual(rc_out_err[1], DATA1))
|
||||
|
||||
# Version where destination filename is explicitly Unicode too.
|
||||
d.addCallback(lambda res: self.do_cli("cp", fn1, "tahoe:" + artonwall_arg + "-2"))
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:" + artonwall_arg + "-2"))
|
||||
d.addCallback(lambda rc_out_err: self.assertEqual(rc_out_err[1], DATA1))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("cp", fn2, "tahoe:"))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:Metallica"))
|
||||
@ -74,7 +79,7 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
if PY2:
|
||||
out = out.decode(get_io_encoding())
|
||||
self.failUnlessReallyEqual(out, u"Metallica\n\u00C4rtonwall\n")
|
||||
self.failUnlessReallyEqual(out, u"Metallica\n\u00C4rtonwall\n\u00C4rtonwall-2\n")
|
||||
self.assertEqual(len(err), 0, err)
|
||||
d.addCallback(_check)
|
||||
|
||||
|
@ -90,6 +90,7 @@ from allmydata.util.time_format import (
|
||||
)
|
||||
from allmydata.util.encodingutil import (
|
||||
quote_output,
|
||||
quote_output_u,
|
||||
to_bytes,
|
||||
)
|
||||
from allmydata.util import abbreviate
|
||||
@ -324,7 +325,7 @@ def humanize_exception(exc):
|
||||
return ("There was already a child by that name, and you asked me "
|
||||
"to not replace it.", http.CONFLICT)
|
||||
if isinstance(exc, NoSuchChildError):
|
||||
quoted_name = quote_output(exc.args[0], encoding="utf-8", quotemarks=False)
|
||||
quoted_name = quote_output_u(exc.args[0], quotemarks=False)
|
||||
return ("No such child: %s" % quoted_name, http.NOT_FOUND)
|
||||
if isinstance(exc, NotEnoughSharesError):
|
||||
t = ("NotEnoughSharesError: This indicates that some "
|
||||
|
Loading…
x
Reference in New Issue
Block a user