File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed
Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,37 @@ predicate ok_to_fail(ImportExpr ie) {
5757 os_specific_import ( ie ) != get_os ( )
5858}
5959
60+
61+ class VersionTest extends @py_flow_node {
62+
63+ VersionTest ( ) {
64+ exists ( string name |
65+ name .matches ( "%version%" ) and
66+ this .( CompareNode ) .getAChild + ( ) .pointsTo ( Module:: named ( "sys" ) .attr ( name ) )
67+ )
68+ }
69+
70+ string toString ( ) {
71+ result = "VersionTest"
72+ }
73+
74+ }
75+
76+ /** A guard on the version of the Python interpreter */
77+ class VersionGuard extends ConditionBlock {
78+
79+ VersionGuard ( ) {
80+ this .getLastNode ( ) instanceof VersionTest
81+ }
82+
83+ }
84+
6085from ImportExpr ie
6186where not ie .refersTo ( _) and
6287 exists ( Context c | c .appliesTo ( ie .getAFlowNode ( ) ) ) and
6388 not ok_to_fail ( ie ) and
6489 not exists ( VersionGuard guard |
65- if guard .isTrue ( ) then
66- guard .controls ( ie .getAFlowNode ( ) .getBasicBlock ( ) , false )
67- else
68- guard .controls ( ie .getAFlowNode ( ) .getBasicBlock ( ) , true )
90+ guard .controls ( ie .getAFlowNode ( ) .getBasicBlock ( ) , _)
6991 )
7092
7193select ie , "Unable to resolve import of '" + ie .getImportedModuleName ( ) + "'."
You can’t perform that action at this time.
0 commit comments