contrib/byteify-strings.py
changeset 39103 da130c5cef90
parent 38391 f77bbd34a1df
child 42247 970aaf38c3fc
--- a/contrib/byteify-strings.py	Wed Aug 15 17:06:12 2018 -0400
+++ b/contrib/byteify-strings.py	Sun Aug 12 14:03:22 2018 +0900
@@ -169,6 +169,11 @@
                 yield adjusttokenpos(t._replace(string=fn[4:]), coloffset)
                 continue
 
+        # Looks like "if __name__ == '__main__'".
+        if (t.type == token.NAME and t.string == '__name__'
+            and _isop(i + 1, '==')):
+            _ensuresysstr(i + 2)
+
         # Emit unmodified token.
         yield adjusttokenpos(t, coloffset)