Fix exception message when creating a response

When you register a handler the type for text or data can be a string or
a callback that provides a string. By the time you get to
create_response this callback should have been called and only a string
can be passed.

This check originally would have been in place for when a callback was
run and the return value was not the expected type, however
create_response is a public function that can be used on its own.

Correct the exception to clarify in create_response you must pass a
string or bytes and not a callback.

Change-Id: I3e700afddc1f40454f69a564066495bfc77d91c8
Closes-Bug: #1627506
This commit is contained in:
voith 2016-09-25 20:49:06 +05:30 committed by Jamie Lennox
parent c105f1cae2
commit 890a4fe9ff

View File

@ -148,9 +148,9 @@ def create_response(request, **kwargs):
encoding = None
if content and not isinstance(content, six.binary_type):
raise TypeError('Content should be a callback or binary data')
raise TypeError('Content should be binary data')
if text and not isinstance(text, six.string_types):
raise TypeError('Text should be a callback or string data')
raise TypeError('Text should be string data')
if json is not None:
text = jsonutils.dumps(json)