[Python-checkins] r55098 - sandbox/trunk/2to3/fixes/fix_unicode.py

guido.van.rossum python-checkins at python.org
Thu May 3 19:18:53 CEST 2007


Author: guido.van.rossum
Date: Thu May  3 19:18:52 2007
New Revision: 55098

Modified:
   sandbox/trunk/2to3/fixes/fix_unicode.py
Log:
The unicode fixer now also translates unichr() to chr().


Modified: sandbox/trunk/2to3/fixes/fix_unicode.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_unicode.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_unicode.py	Thu May  3 19:18:52 2007
@@ -1,4 +1,4 @@
-"""Fixer that changes unicode to str and u"..." into "...".
+"""Fixer that changes unicode to str, unichr to chr, and u"..." into "...".
 
 """
 
@@ -9,7 +9,7 @@
 
 class FixUnicode(basefix.BaseFix):
 
-  PATTERN = "STRING | NAME<'unicode'>"
+  PATTERN = "STRING | NAME<'unicode' | 'unichr'>"
 
   def transform(self, node):
     if node.type == token.NAME:
@@ -17,6 +17,10 @@
         new = node.clone()
         new.value = "str"
         return new
+      if node.value == "unichr":
+        new = node.clone()
+        new.value = "chr"
+        return new
       # XXX Warn when __unicode__ found?
     elif node.type == token.STRING:
       if re.match(r"[uU][rR]?[\'\"]", node.value):


More information about the Python-checkins mailing list