File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
test/query-tests/Statements/no_effect Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,14 @@ predicate in_raises_test(Expr e) {
9595 )
9696}
9797
98+ /** Holds if expression has the form of a Python 2 `print >> out, ...` statement */
99+ predicate python2_print ( Expr e ) {
100+ e .( BinaryExpr ) .getLeft ( ) .( Name ) .getId ( ) = "print" and
101+ e .( BinaryExpr ) .getOp ( ) instanceof RShift
102+ or
103+ python2_print ( e .( Tuple ) .getElt ( 0 ) )
104+ }
105+
98106predicate no_effect ( Expr e ) {
99107 not e instanceof StrConst and
100108 not ( ( StrConst ) e ) .isDocString ( ) and
@@ -107,7 +115,8 @@ predicate no_effect(Expr e) {
107115 not maybe_side_effecting_attribute ( sub )
108116 ) and
109117 not in_notebook ( e ) and
110- not in_raises_test ( e )
118+ not in_raises_test ( e ) and
119+ not python2_print ( e )
111120}
112121
113122from ExprStmt stmt
Original file line number Diff line number Diff line change @@ -133,3 +133,7 @@ def do_action(action):
133133 stop ()
134134 else :
135135 raise ValueError (action )
136+
137+ #Python 2 print
138+ print >> out , message
139+
You can’t perform that action at this time.
0 commit comments