Wednesday, September 28, 2011

Re: DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xdd in position

It sounds like (possibly) there is something broken in your WSGI bootstrapper, or your installation of the django libs is corrupt.

Can you try running this code via './manage.py runserver' and see if you get the same problem?

2011/9/28 Barış Bilgiç <brsbilgic@gmail.com>
I have only used these middleware's
    'django.middleware.common.CommonMiddleware',
    'swfupload.SWFUploadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',

I have change default encoding of python from "ascii" to "utf8" by creating sitecustomize.py under the site-packages. 
But the error log was the same before. Do you have any idea why my wsgireqeust object is corrupted ?

2011/9/28 Cal Leeming [Simplicity Media Ltd] <cal.leeming@simplicitymedialtd.co.uk>
Wtf - why are all the upper case 'i''s being replaced with \xdd??

HTTP_ACCEPT_ENCOD\\xddNG'
HTTP_CONNECT\\xddON
HTTP_COOK\\xddE

Do you have any middleware, third party code or monkeypatches which may be causing this to happen?

Cal

2011/9/28 Barış Bilgiç <brsbilgic@gmail.com>

Hi everyone,

I have a Django Web Application running in Apache with mod_wsgi in my dedicated server with Centos 5.5.

However, sometimes (six or seven times in a day) it starts to give 500 Error for some random pages. But if I refresh the page two or three times, the page turns to normal. But once it starts to give 500 error, every other page in my web site gives that error.

After I restarted the apache, it turns to normal for 5 or 6 hours but it never ends to give that error.

I paste the full error log below but indeed it says that DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xdd in position 330: invalid continuation byte.

What may cause this kind of error and how can I detect it ? I may provide any additional information asap.

PS: I have same setup on my local PC(Apache-mod_wsgi) with Win7 and I have never got this error.

 [Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] mod_wsgi (pid=30331): Exception occurred processing WSGI script '/var/www/html/MY_SITE/django.wsgi'., referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] Traceback (most recent call last):, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 273, in __call__, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     response = self.get_response(request), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info()), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     return debug.technical_500_response(request, *exc_info), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/views/debug.py", line 59, in technical_500_response, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     html = reporter.get_traceback_html(), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/views/debug.py", line 117, in get_traceback_html, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     frame['vars'] = [(k, force_escape(pprint(v))) for k, v in frame['vars']], referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/template/defaultfilters.py", line 34, in _dec, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     args[0] = force_unicode(args[0]), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]   File "/opt/python2.7.1/lib/python2.7/site-packages/django/utils/encoding.py", line 93, in force_unicode, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30]     raise DjangoUnicodeDecodeError(s, *e.args), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xdd in position 330: invalid continuation byte. You passed in "<WSGIRequest\\nGET:<QueryDict: {}>,\\nPOST:<QueryDict: {}>,\\nCOOKIES:{},\\nMETA:{'CSRF_COOKIE': '041ed0a93c4b355d4861a0662d49fcb4',\\n 'DOCUMENT_ROOT': '/var/www/html/MY_SITE',\\n 'GATEWAY_INTERFACE': 'CGI/1.1',\\n 'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',\\n 'HTTP_ACCEPT_ENCOD\\xddNG': 'gzip, deflate',\\n 'HTTP_ACCEPT_LANGUAGE': 'en-us',\\n 'HTTP_CACHE_CONTROL': 'max-age=0',\\n 'HTTP_CONNECT\\xddON': 'keep-alive',\\n 'HTTP_COOK\\xddE': 'csrftoken=10bc570d4ef77b17ce580106dafa9fb6; sessionid=60fb98634573194f7f5e18ef6014f59b',\\n 'HTTP_HOST': 'www.MY_SITE.com',\\n 'HTTP_REFERER': 'http://www.MY_SITE.com/',\\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10',\\n 'PATH_INFO': u'/main/faq/',\\n 'PATH_TRANSLATED': '/var/www/html/MY_SITE/django.wsgi/main/faq/',\\n 'QUERY_STRING': '',\\n 'REMOTE_ADDR': '46.104.250.30',\\n 'REMOTE_PORT': '49643',\\n 'REQUEST_METHOD': 'GET',\\n 'REQUEST_URI': '/main/faq/',\\n 'SCRIPT_FILENAME': '/var/www/html/MY_SITE/django.wsgi',\\n 'SCRIPT_NAME': u'',\\n 'SERVER_ADDR': '93.94.251.82',\\n 'SERVER_ADMIN': 'bilgi@MY_SITE.com',\\n 'SERVER_NAME': 'www.MY_SITE.com',\\n 'SERVER_PORT': '80',\\n 'SERVER_PROTOCOL': 'HTTP/1.1',\\n 'SERVER_SIGNATURE': '<address>Apache/2.2.3 (CentOS) Server at www.MY_SITE.com Port 80</address>\\\\n',\\n 'SERVER_SOFTWARE': 'Apache/2.2.3 (CentOS)',\\n 'mod_wsgi.application_group': 'MY_SITE.com|',\\n 'mod_wsgi.callable_object': 'application',\\n 'mod_wsgi.handler_script': '',\\n 'mod_wsgi.input_chunked': '0',\\n 'mod_wsgi.listener_host': '',\\n 'mod_wsgi.listener_port': '80',\\n 'mod_wsgi.process_group': '',\\n 'mod_wsgi.request_handler': 'wsgi-script',\\n 'mod_wsgi.script_reloading': '1',\\n 'mod_wsgi.version': (3, 3),\\n 'wsgi.errors': <mod_wsgi.Log object at 0x2b7d75ddbfb0>,\\n 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x2b7d75f12a80>,\\n 'wsgi.input': <mod_wsgi.Input object at 0x2b7d75fa0a30>,\\n 'wsgi.multiprocess': True,\\n 'wsgi.multithread': False,\\n 'wsgi.run_once': False,\\n 'wsgi.url_scheme': 'http',\\n 'wsgi.version': (1, 1)}>" (<type 'str'>), referer: http://www.MY_SITE.com/

The web site works seamlessly both in Apache and Django's built-in developer server at my local computer(Win7,Apache,mod_wsgi)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment