[Zope3-checkins] SVN: Zope3/trunk/src/zope/configuration/xmlconfig.py printing the content of the zcml to the console on an error failed if there were non ASCII characters in it

Adam Groszer adamg at fw.hu
Thu Sep 21 06:12:55 EDT 2006


Log message for revision 70281:
  printing the content of the zcml to the console on an error failed if there were non ASCII characters in it
  limitation: the current solution assumes that the zcml's encoding is UTF-8

Changed:
  U   Zope3/trunk/src/zope/configuration/xmlconfig.py

-=-
Modified: Zope3/trunk/src/zope/configuration/xmlconfig.py
===================================================================
--- Zope3/trunk/src/zope/configuration/xmlconfig.py	2006-09-21 09:12:04 UTC (rev 70280)
+++ Zope3/trunk/src/zope/configuration/xmlconfig.py	2006-09-21 10:12:54 UTC (rev 70281)
@@ -169,7 +169,15 @@
                 # Remove text before start if it's noy whitespace
                 lines[0] = lines[0][self.column:]
 
-            src = ''.join([u"  "+l for l in lines])
+            try:
+                src = u''.join([u"  "+l for l in lines])
+            except UnicodeDecodeError:
+                # XXX:
+                # I hope so most internation zcml will use UTF-8 as encoding
+                # otherwise this code must be made more clever
+                src = u''.join([u"  "+l.decode('utf-8') for l in lines])
+                # unicode won't be printable, at least on my console
+                src = src.encode('ascii','replace')
 
         return "%s\n%s" % (`self`, src)
 



More information about the Zope3-Checkins mailing list