Python: Implement traceback module

Just functions, not the classes for now
This commit is contained in:
Rasmus Lerchedahl Petersen
2021-02-03 21:45:18 +01:00
parent 6a45f6e7e0
commit 232d9b006a

View File

@@ -1654,6 +1654,32 @@ private module Stdlib {
class Sqlite3 extends PEP249Module {
Sqlite3() { this = sqlite3() }
}
// ---------------------------------------------------------------------------
// traceback
// ---------------------------------------------------------------------------
/** Gets a reference to the `traceback` module. */
API::Node traceback() { result = API::moduleImport("traceback") }
/**
* Gets a reference to the attribute `attr_name` of the `traceback` module.
*/
private API::Node traceback_attr(string attr_name) { result = traceback().getMember(attr_name) }
/** Provides models for the `traceback` module. */
module traceback {
private class TracebackFunctionCall extends ErrorInfoSource::Range, DataFlow::CfgNode {
override CallNode node;
TracebackFunctionCall() {
node.getFunction() =
traceback_attr([
"extract_tb", "extract_stack", "format_list", "format_exception_only",
"format_exception", "format_exc", "format_tb", "format_stack"
]).getAUse().asCfgNode()
}
}
}
}
// ---------------------------------------------------------------------------