# HG changeset patch # User Yuya Nishihara # Date 1534050202 -32400 # Node ID da130c5cef9014e99dc9a1a85d3578365ad64d86 # Parent 08b2ae9fc030472124b730235de49652a612b759 byteify-strings: prevent "__name__ == '__main__'" from being transformed This was okay for import-time code transformer, but shouldn't be applied to source code. diff -r 08b2ae9fc030 -r da130c5cef90 contrib/byteify-strings.py --- 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)