[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/codegen.py We never want the transformer to upcast to unicode.

Chris McDonough chrism at plope.com
Tue Aug 19 00:56:26 EDT 2008


Log message for revision 89989:
  We never want the transformer to upcast to unicode.
  

Changed:
  U   z3c.pt/trunk/src/z3c/pt/codegen.py

-=-
Modified: z3c.pt/trunk/src/z3c/pt/codegen.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/codegen.py	2008-08-18 23:20:33 UTC (rev 89988)
+++ z3c.pt/trunk/src/z3c/pt/codegen.py	2008-08-19 04:56:24 UTC (rev 89989)
@@ -60,11 +60,8 @@
         self.locals.append(set(dir(__builtin__)))
         
     def visitConst(self, node):
-        if isinstance(node.value, str):
-            try: # If the string is ASCII, return a `str` object
-                node.value.decode('ascii')
-            except ValueError: # Otherwise return a `unicode` object
-                return ast.Const(node.value.decode('utf-8'))
+        if isinstance(node.value, unicode):
+            return ast.Const(node.value.encode('utf-8'))
         return node
 
     def visitAssName(self, node):



More information about the Checkins mailing list