Python examples: Modernize snippets.

This commit is contained in:
Mark Shannon
2019-08-02 10:31:51 +01:00
parent fc4bb028b7
commit 562d959915
9 changed files with 14 additions and 16 deletions

View File

@@ -9,6 +9,6 @@
import python
from Expr e
where e.refersTo(builtin_object(_))
from Expr e, string name
where e.pointsTo(Value::named(name)) and not name.charAt(_) = "."
select e

View File

@@ -8,6 +8,6 @@
import python
from FunctionObject len, CallNode call
from Value len, CallNode call
where len.getName() = "len" and len.getACall() = call
select call

View File

@@ -9,8 +9,8 @@
import python
from ExceptStmt ex, ClassObject cls
from ExceptStmt ex, ClassValue cls
where
cls.getName() = "MyExceptionClass" and
ex.getType().refersTo(cls)
ex.getType().pointsTo(cls)
select ex

View File

@@ -8,7 +8,7 @@
import python
from AstNode call, FunctionObject method
from AstNode call, PythonFunctionValue method
where
method.getQualifiedName() = "MyClass.methodName" and
method.getACall().getNode() = call

View File

@@ -9,8 +9,8 @@
import python
from Call new, ClassObject cls
from Call new, ClassValue cls
where
cls.getName() = "MyClass" and
new.getFunc().refersTo(cls)
new.getFunc().pointsTo(cls)
select new

View File

@@ -13,5 +13,5 @@ where
print instanceof Print
or
/* Python 3 or with `from __future__ import print_function` */
print.(Call).getFunc().refersTo(thePrintFunction())
print.(Call).getFunc().pointsTo(Value::named("print"))
select print

View File

@@ -9,12 +9,10 @@
import python
from Raise raise, ClassObject ex
from Raise raise, ClassValue ex
where
ex.getName() = "AnException" and
(
raise.getException().refersTo(ex.getAnImproperSuperType())
or
raise.getException().refersTo(_, ex.getAnImproperSuperType(), _)
raise.getException().pointsTo(ex.getASuperType())
)
select raise, "Don't raise instances of 'AnException'"

View File

@@ -8,6 +8,6 @@
import python
from FunctionObject f
where f.getACallee() = f
from PythonFunctionValue f
where f.getACall().getScope() = f.getScope()
select f

View File

@@ -14,5 +14,5 @@ import python
from SubscriptNode store
where
store.isStore() and
store.getIndex().refersTo(theNoneObject())
store.getIndex().pointsTo(Value::named("None"))
select store