black/tests/python2.py
Łukasz Langa 6316e293ac Automatic detection of deprecated Python 2 forms of print and exec
Note: if those are handled, you can't use --safe because this check is using
Python 3.6+ builtin AST.

Fixes #49
2018-03-22 23:19:23 -07:00

34 lines
600 B
Python

#!/usr/bin/env python2
import sys
print >> sys.stderr , "Warning:" ,
print >> sys.stderr , "this is a blast from the past."
print >> sys.stderr , "Look, a repr:", `sys`
def function((_globals, _locals)):
exec "print 'hi from exec!'" in _globals, _locals
function((globals(), locals()))
# output
#!/usr/bin/env python2
import sys
print >>sys.stderr, "Warning:",
print >>sys.stderr, "this is a blast from the past."
print >>sys.stderr, "Look, a repr:", ` sys `
def function((_globals, _locals)):
exec "print 'hi from exec!'" in _globals, _locals
function((globals(), locals()))