Skip to content

Commit 3ee7566

Browse files
committed
Python: add missing qldoc
also add to ordinary `except`
1 parent 71335a1 commit 3ee7566

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

python/ql/lib/semmle/python/essa/Essa.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ class ExceptionCapture extends EssaNodeDefinition {
517517
SsaSource::exception_capture(this.getSourceVariable(), this.getDefiningNode())
518518
}
519519

520+
/**
521+
* Gets the type handled by this exception handler
522+
* `ExceptionType` in `except ExceptionType as ex:`.
523+
*/
520524
ControlFlowNode getType() {
521525
exists(ExceptGroupFlowNode ex |
522526
ex.getName() = this.getDefiningNode() and
@@ -535,6 +539,10 @@ class ExceptionGroupCapture extends EssaNodeDefinition {
535539
SsaSource::exception_group_capture(this.getSourceVariable(), this.getDefiningNode())
536540
}
537541

542+
/**
543+
* Gets the type handled by this exception handler
544+
* `ExceptionType` in `except* ExceptionType as ex:`.
545+
*/
538546
ControlFlowNode getType() {
539547
exists(ExceptGroupFlowNode ex |
540548
ex.getName() = this.getDefiningNode() and

python/ql/lib/semmle/python/types/Exceptions.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ predicate scope_raises_unknown(Scope s) {
367367
class ExceptFlowNode extends ControlFlowNode {
368368
ExceptFlowNode() { this.getNode() instanceof ExceptStmt }
369369

370+
/**
371+
* Gets the type handled by this exception handler.
372+
* `ExceptionType` in `except ExceptionType as e:`
373+
*/
370374
ControlFlowNode getType() {
371375
exists(ExceptStmt ex |
372376
this.getBasicBlock().dominates(result.getBasicBlock()) and
@@ -375,6 +379,10 @@ class ExceptFlowNode extends ControlFlowNode {
375379
)
376380
}
377381

382+
/**
383+
* Gets the name assigned to the handled exception, if any.
384+
* `e` in `except ExceptionType as e:`
385+
*/
378386
ControlFlowNode getName() {
379387
exists(ExceptStmt ex |
380388
this.getBasicBlock().dominates(result.getBasicBlock()) and
@@ -443,11 +451,19 @@ class ExceptFlowNode extends ControlFlowNode {
443451
class ExceptGroupFlowNode extends ControlFlowNode {
444452
ExceptGroupFlowNode() { this.getNode() instanceof ExceptGroupStmt }
445453

454+
/**
455+
* Gets the type handled by this exception handler.
456+
* `eg` in `except* eg as e:`
457+
*/
446458
ControlFlowNode getType() {
447459
this.getBasicBlock().dominates(result.getBasicBlock()) and
448460
result = this.getNode().(ExceptGroupStmt).getType().getAFlowNode()
449461
}
450462

463+
/**
464+
* Gets the name assigned to the handled exception, if any.
465+
* `e` in `except* eg as e:`
466+
*/
451467
ControlFlowNode getName() {
452468
this.getBasicBlock().dominates(result.getBasicBlock()) and
453469
result = this.getNode().(ExceptGroupStmt).getName().getAFlowNode()

0 commit comments

Comments
 (0)