Make DebugFilesKeyError.__str__ return str on 3.x

This commit is contained in:
Daniel Neuhäuser 2013-05-22 21:07:53 +02:00
parent 3f80b0fd6c
commit 4bea6bbe6d

View file

@ -8,6 +8,7 @@
:copyright: (c) 2011 by Armin Ronacher. :copyright: (c) 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details. :license: BSD, see LICENSE for more details.
""" """
from flask._compat import implements_to_string
class UnexpectedUnicodeError(AssertionError, UnicodeError): class UnexpectedUnicodeError(AssertionError, UnicodeError):
@ -16,6 +17,7 @@ class UnexpectedUnicodeError(AssertionError, UnicodeError):
""" """
@implements_to_string
class DebugFilesKeyError(KeyError, AssertionError): class DebugFilesKeyError(KeyError, AssertionError):
"""Raised from request.files during debugging. The idea is that it can """Raised from request.files during debugging. The idea is that it can
provide a better error message than just a generic KeyError/BadRequest. provide a better error message than just a generic KeyError/BadRequest.
@ -33,7 +35,7 @@ class DebugFilesKeyError(KeyError, AssertionError):
buf.append('\n\nThe browser instead transmitted some file names. ' buf.append('\n\nThe browser instead transmitted some file names. '
'This was submitted: %s' % ', '.join('"%s"' % x 'This was submitted: %s' % ', '.join('"%s"' % x
for x in form_matches)) for x in form_matches))
self.msg = ''.join(buf).encode('utf-8') self.msg = ''.join(buf)
def __str__(self): def __str__(self):
return self.msg return self.msg