arrow
Return

Detecting and Explaining Python Name Errors

delete2025-02-01
delete0
PRE
AI
J
Jiawei Wang *
L
Li Li
刘奎 (Kui Liu)
DOI:10.1016/j.infsof.2024.107592delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Python has become one of the most popular programming languages nowadays but has not received enough attention from the software engineering community. Many errors, either fixed or not yet, have been scattered in the lifetime of Python projects, including popular Python libraries that have already been reused. NameError is among one of those errors that are widespread in the Python community, as confirmed in our empirical study. Yet, our community has not put effort into helping developers mitigate its introductions. To fill this gap, we propose in this work a static analysis-based approach called DENE (short for D etecting and E xplaining N ame E rrors) to automatically detect and explain name errors in Python projects. To this end, DENE builds control-flow graphs for Python projects and leverages a scope-aware reaching definition analysis to locate identifiers that may cause name errors at runtime and report their locations. Experimental results on carefully crafted ground truth demonstrate that DENE is effective in detecting name errors in real-world Python projects. The results also confirm that unknown name errors are still widely presented in popular Python projects and libraries, and the outputs of DENE can indeed help developers understand why the name errors are flagged as such.
Keywords:
Static analysis
Python code
Tools
Empirical studies

Journal

Information and Software Technology cover
Information and Software Technology
IF:
4.3
Papers:
3.7K
Citations:
7.7K

Organization

M
Monash University
Scholars:
5.4W
Papers: 5.4W
Citations: 79
H
huawei technologies
Scholars:
3.3K
Papers: 2.9K
Citations: 1
B
Beihang University
Scholars:
5.1W
Papers: 4.1W
Citations: 37
researcher View more organizations