UnicodeDecodeError 'ascii' codec can't decode byte 0xc2 in position 13: ordinal not in range(128)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

UnicodeDecodeError 'ascii' codec can't decode byte 0xc2 in position 13: ordinal not in range(128)

Shaun@UMB
Greetings!

We have an English language site. I recently tried to change the Copyright info on a course, and now the course is not able to be viewed. I get a UnicodeDecodeError. To reproduce:
1) Select Course or Division
2) Select Edit
3) Select Ownership
4) Change any value on this page
5) Select Save

Expected result: Changes saved, redirect to course or division page
Actual result: Errors (traceback included in post)


.

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CMFCore.FSPageTemplate, line 155, in pt_render
  Module Products.PageTemplates.PageTemplate, line 89, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 525, in do_optTag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 221, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/opt/educommons-umb/Zope-2.10.5/web/Products/eduCommons/skins/eduCommons/division_listing.pt
   - Line 52, Column 8
   - Expression: <PathExpr standard:u'context/@@metadata_view|nothing'>
   - Names:
      {'container': <PloneSite at /eduCommons>,
       'context': <Division at /eduCommons/communications-studies>,
       'default': ,
       'here': <Division at /eduCommons/communications-studies>,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x1bf075cc>,
       'request': <HTTPRequest, URL=http://ocw.umb.edu:8080/eduCommons/communications-studies/division_listing>,
       'root': <Application at >,
       'template': <FSPageTemplate at /eduCommons/division_listing used for /eduCommons/communications-studies>,
       'traverse_subpath': [],
       'user': <PloneUser 'administrator'>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 161, in _eval
  Module Products.PageTemplates.Expressions, line 123, in render
  Module Products.Five.browser.metaconfigure, line 417, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 129, in _exec
  Module Products.PageTemplates.PageTemplate, line 89, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 221, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
   - URL: index
   - Line 2, Column 0
   - Expression: <PathExpr standard:'view/writeRDF'>
   - Names:
      {'container': <Division at /eduCommons/communications-studies>,
       'context': <Division at /eduCommons/communications-studies>,
       'default': ,
       'here': <Division at /eduCommons/communications-studies>,
       'loop': {},
       'nothing': None,
       'options': {'args': (<Products.Five.metaclass.SimpleViewClass from /opt/educommons-umb/Zope-2.10.5/web/Products/ContentLicensing/browser/metadata_view.pt object at 0x138116ac>,)},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xe529acc>,
       'request': <HTTPRequest, URL=http://ocw.umb.edu:8080/eduCommons/communications-studies/division_listing>,
       'root': <Application at >,
       'template': <ImplicitAcquirerWrapper object at 0x162f86cc>,
       'traverse_subpath': [],
       'user': <PloneUser 'administrator'>,
       'view': <Products.Five.metaclass.SimpleViewClass from /opt/educommons-umb/Zope-2.10.5/web/Products/ContentLicensing/browser/metadata_view.pt object at 0x138116ac>,
       'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0x197e220c>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 161, in _eval
  Module Products.PageTemplates.Expressions, line 123, in render
  Module Products.eduCommons.browser, line 339, in writeRDF
  Module Products.eduCommons.browser, line 391, in getCCLicenseRDF
  Module xml.dom.minidom, line 62, in toprettyxml
  Module StringIO, line 271, in getvalue
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 13: ordinal not in range(128)
--
I can add a new license through Site Setup, I can even switch this new license to site default without problems.

It seems to be when I change the copyright info for an individual course, it causes this error. Sometimes it causes the problem and doesn't save the changes (which allows me to see the course, nothing changed). Sometimes it throws the error and I cannot access the course or 'division'/department page afterwards(the object I was trying to change).



Here is an example of a similar error we get <when try for individual course copyright info change>:

Exception Type: UnicodeEncodeError
Exception Value 'ascii' codec can't encode character u'\u2019' in position 412: ordinal not in range(128)


Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 28, in _call
  Module Products.CMFFormController.ControllerBase, line 231, in getNext
  Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPythonScript, line 106, in __call__
  Module Products.CMFFormController.ControllerBase, line 231, in getNext
  Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPythonScript, line 104, in __call__
  Module Products.CMFFormController.Script, line 145, in __call__
  Module Products.CMFCore.FSPythonScript, line 140, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 196, in _exec
  Module None, line 1, in content_edit
   - <FSControllerPythonScript at /eduCommons/content_edit used for /eduCommons/speg/speg-623>
   - Line 1
  Module Products.CMFCore.FSPythonScript, line 140, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 196, in _exec
  Module None, line 13, in content_edit_impl
   - <FSPythonScript at /eduCommons/content_edit_impl used for /eduCommons/speg/speg-623>
   - Line 13
  Module Products.Archetypes.BaseObject, line 655, in processForm
  Module Products.ContentLicensing.DublinCoreExtensions.patch, line 45, in new_func
  Module Products.ContentLicensing.DublinCoreExtensions.patch, line 39, in notifyObjectModified
  Module zope.event, line 23, in notify
  Module zope.component.event, line 26, in dispatch
  Module zope.component._api, line 130, in subscribers
  Module zope.component.registry, line 290, in subscribers
  Module zope.interface.adapter, line 535, in subscribers
  Module zope.component.event, line 33, in objectEventNotify
  Module zope.component._api, line 130, in subscribers
  Module zope.component.registry, line 290, in subscribers
  Module zope.interface.adapter, line 535, in subscribers
  Module Products.eduCommons.eventHandlers, line 565, in updateZipDownload
  Module Products.eduCommons.eventHandlers, line 600, in validateContext
  Module Products.eduCommons.eventHandlers, line 624, in createZipFile
  Module Products.eduCommons.eventHandlers, line 665, in getZipFileData
  Module Products.ZipFileTransport.utilities.utils, line 353, in _getAllObjectsData
  Module zipfile, line 460, in writestr
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 412: ordinal not in range(128)

Thanks for reading- looking forward to your thoughts,
Shaun
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UnicodeDecodeError 'ascii' codec can't decode byte 0xc2 in position 13: ordinal not in range(128)

Shaun@UMB-2
I have found a way to reproduce an error likely related to what is happening (which may be fixed in newer versions of educommons)

1) Select Course or Division
2) Select Edit
3) Select Ownership
4) Under "Rights", Adding a © will cause problems
5) Select Save

So we just stopped using © to mark Copyright for this part of our site.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UnicodeDecodeError 'ascii' codec can't decode byte 0xc2 in position 13: ordinal not in range(128)

David Ray
Administrator
Valuable information, thanks for tracking that down.

Looks like the ContentLicensing engine needs to either have a validator in place, or better account for non-ascii characters in some/all fields.

Again, thanks for doing the labor of pinpointing one of the issues. It's that much more helpful for future development/fixes against the code.

David
---------------------
David Ray
Applications Analyst
Lineberger Comprehsensive Cancer Center
University of North Carolina at Chapel Hill
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UnicodeDecodeError 'ascii' codec can't decode byte 0xc2 in position 13: ordinal not in range(128)

Naotaka Jay Hotta
In reply to this post by Shaun@UMB
"Module StringIO, line 271, in getvalue" is caused by Python 2.4's known bug.

I will advise you to set sitecustomize.py in your python lib's sitepackage directory to handle no-ascii code.

in sitecustomize.py just write:

import sys
sys.setdefaultencoding("utf-8")

However, this magic file will eagerly hide all UnicodeDecode Errors of plone.  
So, please take a second to consider if it is acceptable.
Loading...