Skip to content
#software testing Open access

Exception handling bugs in Python: An empirical study of root causes, fix patterns, and anti-patterns

Nov 2026 · Information and Software Technology · 0 citations · 70 references

TL;DR

Analysis of exception handling bugs in Python projects reveals systematic relationships between root causes and repair strategies, indicating that exception handling bugs often follow predictable patterns.

Abstract

Context: Exception handling mechanisms are designed to manage abnormal events that disrupt normal program execution, helping software recover from unexpected situations. However, defects in exception handling mechanisms can introduce errors, crashes, and unexpected behavior, reducing system reliability. Despite widespread adoption of Python, exception handling bugs in Python projects remain largely underexplored. Objectives: This study aims to investigate the characteristics of exception handling bugs in Python projects by analyzing their root causes, fix patterns, and their relationship with anti-patterns (exception handling anti-patterns). Methods: We conducted a large-scale empirical study on 550 open-source Python projects. Using our Exception Miner tool and manual validation, we analyzed 942 confirmed exception handling bugs identified from 1,649 bug candidates extracted from issue reports and associated commits. Results: Our analysis identified 12 root causes and 25 fix patterns. The most common root cause is Unhandled Exception , accounting for 50.64% of the analyzed cases. The most frequent repair strategies include adding exception handling blocks, changing exception types, and introducing appropriate raise conditions, which together account for approximately 60% of the fixes. A before-and-after analysis shows that many exception handling anti-patterns were preserved from the buggy version, while fixes still introduced an increase of 196 exception handling anti-patterns occurrences. Conclusion: The results reveal systematic relationships between root causes and repair strategies, indicating that exception handling bugs often follow predictable patterns. These findings provide insights to improve testing practices and design automated tools to detect and repair exception handling bugs in Python projects.

Read PDF

Similar papers

Preprint Jul 2026

How Do LLMs Read Bug Reports? An Empirical Study of Attention in LLMs for Automated Program Repair

The first empirical study of attention patterns in LLM-based program repair is presented, providing interpretable insights into how models process bug reports and where their attention is concentrated during repair, and indicates that stronger alignment between model attention and developer-identified key sections and phrases is associated with higher repair success.

Ramtin Ehsani, Irene Manotas, Saurabh Pujar et al. · 0 citations
Open access Jun 2026

Mining Long Tail Bugs: Identifying Rare and Overlooked Issues in Code

LTMiner, which mines rare patterns from large-scale projects and detects potential bugs by checking for violations of these patterns, effectively curbs pattern explosion and false positives, uncovering previously unknown bugs in large-scale projects at an acceptable cost.

Wentao Liang, Yanjun Wu, Xiang Ling et al. · 0 citations
Open access Jun 2026

Detecting Bugs in Rust Compiler Fix Suggestions via Constraint-Violation-Guided Mutation

SugBreaker is presented, an automated testing framework specifically designed to validate rustc's suggestions that injects type-related, borrow-related, and lifetime-related errors into valid Rust programs to trigger compiler diagnostics and iteratively verify the correctness of suggested fixes.

Zixi Liu, Yang Feng, Jialiang Jiang et al. · 0 citations
Open access Jun 2026

From Suspicious Signals to Crashes: Guiding Bug-Driven GUI Testing via Code-Inspired Tracing

TraceDroid is proposed, a novel automated GUI testing approach that leverages suspicious code-level signals to guide dynamic exploration and successfully detects 21 previously unknown crash bugs in 116 popular Google Play apps, demonstrating its effectiveness in real-world scenarios.

Mengzhuo Chen, Zhe Liu, Chunyang Chen et al. · 0 citations
Preprint Aug 2026

CodeMechanic: Bug-Property-Guided Program Mitigation

This work presents CodeMechanic, a bug-property-guided system for generating constrained mit- igations for spatial memory corruption that combines a two-dimensional static and dynamic context extractor with in-prompt debugging knowledge and stepwise val- idation to limit the effect of LLM errors.

Han Zheng, Rafaila Galanopoulou, Ilia Shumailov et al. · 0 citations
Preprint Jul 2026

READU: Inconsistency-Driven Just-in-Time Detection and Repair of README Bugs

ReadU is an inconsistency-driven technique for just-in-time detection and repair of README bugs that applies a high-recall commit filter, runs internal and external consistency checkers in parallel, uses an alert judge to remove false positives, and automatically synthesizes documentation patches.

Doehyun Baek, Kilian Krampf, Michael Pradel · 0 citations

Related blog posts

MIT News · Artificial Intelligence Aug 17, 2026

Q&A: Rethinking how innovation happens

In his latest book, Professor Eugene Fitzgerald examines the forces that turn breakthroughs into value — and why innovation resists simple formulas.