Opened 12 years ago

Last modified 12 years ago

#19101 closed Bug

Non ascii chars in form cause Internal Server Error — at Initial Version

Reported by: kristall Owned by: nobody
Component: Forms Version: dev
Severity: Release blocker Keywords: encoding
Cc: kristall Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Trying to use non ascii chars in form cause trouble with python3.2 (same code works fine under python2.7).
I used "python3 manage.py runserver"

Internal Server Error: /formtest/
Traceback (most recent call last):

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/base.py", line 110, in get_response

response = middleware_method(request, callback, callback_args, callback_kwargs)

File "/usr/local/lib/python3.2/site-packages/django/middleware/csrf.py", line 174, in process_view

request_csrf_token = request.POST.get('csrfmiddlewaretoken', )

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/wsgi.py", line 179, in _get_post

self._load_post_and_files()

File "/usr/local/lib/python3.2/site-packages/django/http/init.py", line 340, in _load_post_and_files

self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict()

File "/usr/local/lib/python3.2/site-packages/django/http/init.py", line 392, in init

encoding=encoding):

File "/usr/local/lib/python3.2/urllib/parse.py", line 608, in parse_qsl

value = _coerce_result(value)

File "/usr/local/lib/python3.2/urllib/parse.py", line 88, in _encode_result

return obj.encode(encoding, errors)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Traceback (most recent call last):

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/base.py", line 110, in get_response

response = middleware_method(request, callback, callback_args, callback_kwargs)

File "/usr/local/lib/python3.2/site-packages/django/middleware/csrf.py", line 174, in process_view

request_csrf_token = request.POST.get('csrfmiddlewaretoken', )

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/wsgi.py", line 179, in _get_post

self._load_post_and_files()

File "/usr/local/lib/python3.2/site-packages/django/http/init.py", line 340, in _load_post_and_files

self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict()

File "/usr/local/lib/python3.2/site-packages/django/http/init.py", line 392, in init

encoding=encoding):

File "/usr/local/lib/python3.2/urllib/parse.py", line 608, in parse_qsl

value = _coerce_result(value)

File "/usr/local/lib/python3.2/urllib/parse.py", line 88, in _encode_result

return obj.encode(encoding, errors)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.2/wsgiref/handlers.py", line 137, in run

self.result = application(self.environ, self.start_response)

File "/usr/local/lib/python3.2/site-packages/django/contrib/staticfiles/handlers.py", line 71, in call

return self.application(environ, start_response)

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/wsgi.py", line 236, in call

response = self.get_response(request)

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/base.py", line 180, in get_response

response = self.handle_uncaught_exception(request, resolver, sys.exc_info())

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/base.py", line 222, in handle_uncaught_exception

return debug.technical_500_response(request, *exc_info)

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 69, in technical_500_response

html = reporter.get_traceback_html()

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 289, in get_traceback_html

c = Context(self.get_traceback_data())

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 247, in get_traceback_data

frames = self.get_traceback_frames()

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 398, in get_traceback_frames

'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 197, in get_traceback_frame_variables

value = self.get_request_repr(value)

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 105, in get_request_repr

return build_request_repr(request, POST_override=self.get_post_parameters(request))

File "/usr/local/lib/python3.2/site-packages/django/views/debug.py", line 154, in get_post_parameters

return request.POST

File "/usr/local/lib/python3.2/site-packages/django/core/handlers/wsgi.py", line 179, in _get_post

self._load_post_and_files()

File "/usr/local/lib/python3.2/site-packages/django/http/init.py", line 340, in _load_post_and_files

self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict()

File "/usr/local/lib/python3.2/site-packages/django/http/init.py", line 392, in init

encoding=encoding):

File "/usr/local/lib/python3.2/urllib/parse.py", line 608, in parse_qsl

value = _coerce_result(value)

File "/usr/local/lib/python3.2/urllib/parse.py", line 88, in _encode_result

return obj.encode(encoding, errors)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Change History (2)

by kristall, 12 years ago

Attachment: forms.py added

The used form

by kristall, 12 years ago

Attachment: views.py added

The used view

Note: See TracTickets for help on using tickets.
Back to Top