#9935: When used with Oracle XE, admin page throws UnicodeEncodeError ----------------------------------------------+----------------------------- Reporter: jamesli | Owner: nobody Status: new | Milestone: post-1.0 Component: django.contrib.sessions | Version: 1.0 Resolution: | Keywords: oracle admin UnicodeEncodeError Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ----------------------------------------------+----------------------------- Changes (by kmtracey):
* needs_better_patch: => 0 * component: django.contrib.admin => django.contrib.sessions * needs_tests: => 0 * needs_docs: => 0 Old description: > I can reproduce the problem with the following environment: > Windows XP Pro > Python 2.5.2 > Oracle 10g XE (Universal) > Django 1.0.2 final > > (I tend to think it is a Django/Oracle combination problem, because I > can't reproduce the bug with MySQL or Postgres.) > > I was walking through the tutorial, during which I installed the 'admin' > site. I went to http://127.0.0.1:8000/admin/ and logged in with user name > and password, and then hit the following error. > > UnicodeEncodeError at /admin/ > > 'ascii' codec can't encode characters in position 0-42: ordinal not in > range(128) > > Request Method: POST > Request URL: http://127.0.0.1:8000/admin/ > Exception Type: UnicodeEncodeError > Exception Value: > > 'ascii' codec can't encode characters in position 0-42: ordinal not in > range(128) > > Exception Location: C:\Python25\lib\base64.py in decodestring, line > 321 > Python Executable: C:\Python25\python.exe > Python Version: 2.5.2 > Python Path: ['C:\\django\\mysite', 'C:\\IBMTOOLS\\utils\\support', > 'C:\\IBMTOOLS\\utils\\logger', 'C:\\WINDOWS\\system32\\python25.zip', > 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', > 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site- > packages'] > Server time: Tue, 30 Dec 2008 19:42:28 -0800 > Unicode error hint > > The string that could not be encoded/decoded was: > 䅧㥊兣噆湃汒㍣橒㉢爹坡硖汁䝕㉤礹㉡歖兣穎浌穑呏硫坚歊浍㑍呎祉呙硉䝏㉍橙穑呚橊娊則奫婺੬zOTkx > > Traceback: > Environment: > > Request Method: POST > Request URL: http://127.0.0.1:8000/admin/ > Django Version: 1.0.2 final > Python Version: 2.5.2 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.admin'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > Traceback: > File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in > get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in > root > 140. if not self.has_permission(request): > File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in > has_permission > 99. return request.user.is_authenticated() and > request.user.is_staff > File "C:\Python25\Lib\site-packages\django\contrib\auth\middleware.py" in > __get__ > 5. request._cached_user = get_user(request) > File "C:\Python25\Lib\site-packages\django\contrib\auth\__init__.py" in > get_user > 83. user_id = request.session[SESSION_KEY] > File "C:\Python25\Lib\site- > packages\django\contrib\sessions\backends\base.py" in __getitem__ > 46. return self._session[key] > File "C:\Python25\Lib\site- > packages\django\contrib\sessions\backends\base.py" in _get_session > 172. self._session_cache = self.load() > File "C:\Python25\Lib\site- > packages\django\contrib\sessions\backends\db.py" in load > 18. return self.decode(force_unicode(s.session_data)) > File "C:\Python25\Lib\site- > packages\django\contrib\sessions\backends\base.py" in decode > 93. encoded_data = base64.decodestring(session_data) > File "C:\Python25\lib\base64.py" in decodestring > 321. return binascii.a2b_base64(s) > > Exception Type: UnicodeEncodeError at /admin/ > Exception Value: 'ascii' codec can't encode characters in position 0-42: > ordinal not in range(128) New description: I can reproduce the problem with the following environment: Windows XP Pro Python 2.5.2 Oracle 10g XE (Universal) Django 1.0.2 final (I tend to think it is a Django/Oracle combination problem, because I can't reproduce the bug with MySQL or Postgres.) I was walking through the tutorial, during which I installed the 'admin' site. I went to http://127.0.0.1:8000/admin/ and logged in with user name and password, and then hit the following error. {{{ UnicodeEncodeError at /admin/ 'ascii' codec can't encode characters in position 0-42: ordinal not in range(128) Request Method: POST Request URL: http://127.0.0.1:8000/admin/ Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode characters in position 0-42: ordinal not in range(128) Exception Location: C:\Python25\lib\base64.py in decodestring, line 321 Python Executable: C:\Python25\python.exe Python Version: 2.5.2 Python Path: ['C:\\django\\mysite', 'C:\\IBMTOOLS\\utils\\support', 'C:\\IBMTOOLS\\utils\\logger', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site- packages'] Server time: Tue, 30 Dec 2008 19:42:28 -0800 Unicode error hint The string that could not be encoded/decoded was: 䅧㥊兣噆湃汒㍣橒㉢爹坡硖汁䝕㉤礹㉡歖兣穎浌穑呏硫坚歊浍㑍呎祉呙硉䝏㉍橙穑呚橊娊則奫婺੬zOTkx Traceback: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.0.2 final Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in root 140. if not self.has_permission(request): File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in has_permission 99. return request.user.is_authenticated() and request.user.is_staff File "C:\Python25\Lib\site-packages\django\contrib\auth\middleware.py" in __get__ 5. request._cached_user = get_user(request) File "C:\Python25\Lib\site-packages\django\contrib\auth\__init__.py" in get_user 83. user_id = request.session[SESSION_KEY] File "C:\Python25\Lib\site- packages\django\contrib\sessions\backends\base.py" in __getitem__ 46. return self._session[key] File "C:\Python25\Lib\site- packages\django\contrib\sessions\backends\base.py" in _get_session 172. self._session_cache = self.load() File "C:\Python25\Lib\site- packages\django\contrib\sessions\backends\db.py" in load 18. return self.decode(force_unicode(s.session_data)) File "C:\Python25\Lib\site- packages\django\contrib\sessions\backends\base.py" in decode 93. encoded_data = base64.decodestring(session_data) File "C:\Python25\lib\base64.py" in decodestring 321. return binascii.a2b_base64(s) Exception Type: UnicodeEncodeError at /admin/ Exception Value: 'ascii' codec can't encode characters in position 0-42: ordinal not in range(128) }}} Comment: (Fixed formatting.) FWIW, this is not generally re-creatable. I've got Oracle 10g XE on a Windows box with Python 2.5.2 and have no trouble using using the admin interface with that setup. I suspect the problem may be some configuration issue but I don't know enough about Oracle or contrib.sessions to say what might be going wrong in your case. -- Ticket URL: <http://code.djangoproject.com/ticket/9935#comment:1> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---