On 16 August 2011 22:21, Manuel Antonio Mora Sandoval
<[email protected]> wrote:
> OK, my version de python is 3.2.1and version of mod_wsgi is the same of the
> repository.
> Teh error is:
> [Tue Aug 16 06:22:42 2011] [error] [client 200.31.89.116] mod_wsgi
> (pid=8786): Exception occurred processing WSGI script
> '/srv/development/scripts/myapp.wsgi'.
> [Tue Aug 16 06:22:42 2011] [error] [client 200.31.89.116] TypeError:
> sequence of byte string values expected, value of type str found
> And source is:
> def application(environ, start_response):
>      status = '200 OK'
>      output = 'Hello World!'
>      response_headers = [('Content-type', 'text/plain'),
>                          ('Content-Length', str(len(output)))]
>      start_response(status, response_headers)
>      return [output]
>
> but if I use " output = b'Hello World!' ", then this works.

Which is correct, the output for a Python 3.X WSGI application must be
a stream of bytes and cannot be Unicode.

See:

  http://www.python.org/dev/peps/pep-3333/

BTW, make sure you don't pay too much attention to:

  http://code.google.com/p/modwsgi/wiki/SupportForPython3X

It is out of date.

The mod_wsgi in source code repository is more closely aligned with
final WSGI PEP 3333 and is more strict than what the wiki page
describes.

Adhere to WSGI PEP 3333 and code will still work on mod_wsgi.

Graham

> You tell me if you need more information.
>
> 2011/8/11 Graham Dumpleton <[email protected]>
>>
>> BTW, can you supply the full error with any traceback as well so can
>> work out what actual part of code this is occurring in.
>>
>> Graham
>>
>> On 12 August 2011 09:09, Graham Dumpleton <[email protected]>
>> wrote:
>> > On 12 August 2011 05:22, mams.827 <[email protected]> wrote:
>> >> Hi, I installed the module, but when I test, show the Error: "sequence
>> >> of byte string values expected, value of type str found".
>> >
>> > Can you clarify which mod_wsgi version and which Python version you are
>> > using.
>> >
>> >> I changed the return in the example.
>> >>
>> >>
>> >> def application(environ, start_response):
>> >>    status = '200 OK'
>> >>    output = b'Hello World!'
>> >>    response_headers = [('Content-type', 'text/plain'),
>> >>                        ('Content-Length', str(len(output)))]
>> >>    start_response(status, response_headers)
>> >>
>> >>    return [bytes(output, 'utf-8')]    // I Change this
>> >
>> > If this is for Python 3.X, then 'output' is already bytes and so you
>> > wouldn't need to do:
>> >
>> >  bytes(output, 'utf-8')
>> >
>> > If I do that on Python 3.2 I get:
>> >
>> >>>> bytes(output, 'utf-8')
>> > Traceback (most recent call last):
>> >  File "<stdin>", line 1, in <module>
>> > TypeError: encoding or errors without a string argument
>> >
>> > So, shouldn't even get into mod_wsgi. Thus why want to clarify which
>> > versions of things you are using.
>> >
>> > Graham
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "modwsgi" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/modwsgi?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to