[Zope3-checkins] SVN: Zope3/branches/3.3/ - Fixed bug #738: RestrictedPython was unable to parse$ Unicode expressions

Christian Theune ct at gocept.com
Mon Dec 11 12:35:43 EST 2006


Log message for revision 71528:
  - Fixed bug #738: RestrictedPython was unable to parse$ Unicode expressions
    correctly (as passed in from e.g. ZPTPages).$
  
  

Changed:
  U   Zope3/branches/3.3/doc/CHANGES.txt
  U   Zope3/branches/3.3/src/RestrictedPython/RCompile.py
  U   Zope3/branches/3.3/src/RestrictedPython/tests/testRestrictions.py

-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt	2006-12-11 17:27:06 UTC (rev 71527)
+++ Zope3/branches/3.3/doc/CHANGES.txt	2006-12-11 17:35:42 UTC (rev 71528)
@@ -10,6 +10,9 @@
 
     Bugfixes
 
+      - Fixed bug #738: RestrictedPython was unable to parse
+        Unicode expressions correctly (as passed in from e.g. ZPTPages).
+
       - Fixed bug #723: Testbrowser was handling multiple submit buttons with
         the same name incorrectly.
 

Modified: Zope3/branches/3.3/src/RestrictedPython/RCompile.py
===================================================================
--- Zope3/branches/3.3/src/RestrictedPython/RCompile.py	2006-12-11 17:27:06 UTC (rev 71527)
+++ Zope3/branches/3.3/src/RestrictedPython/RCompile.py	2006-12-11 17:35:42 UTC (rev 71528)
@@ -25,6 +25,10 @@
 
 
 def niceParse(source, filename, mode):
+    if isinstance(source, unicode):
+        # Use the utf-8-sig BOM so the compiler
+        # detects this as a UTF-8 encoded string.
+        source = '\xef\xbb\xbf' + source.encode('utf-8')
     try:
         return parse(source, mode)
     except:

Modified: Zope3/branches/3.3/src/RestrictedPython/tests/testRestrictions.py
===================================================================
--- Zope3/branches/3.3/src/RestrictedPython/tests/testRestrictions.py	2006-12-11 17:27:06 UTC (rev 71527)
+++ Zope3/branches/3.3/src/RestrictedPython/tests/testRestrictions.py	2006-12-11 17:35:42 UTC (rev 71528)
@@ -448,6 +448,7 @@
 
 create_rmodule()
 
+
 def test_suite():
     return unittest.makeSuite(RestrictionTests, 'check')
 



More information about the Zope3-Checkins mailing list