🤖 AI Summary
Python third-party library API parameter evolution frequently causes client-side compatibility issues, yet existing tools lack automated detection and repair capabilities. This paper introduces PyFix, the first end-to-end automated framework for API compatibility management, encompassing API extraction, instrumentation, semantic mapping, compatibility assessment, patch generation, and validation. We formally model five categories of parameter changes—addition, removal, modification, reordering, and positional-to-keyword conversion—and design a rule-driven repair engine coupled with a multi-dimensional verification mechanism. Furthermore, we construct PCBENCH, the first large-scale benchmark comprising 47,478 real-world test cases. Experimental results show that PyFix achieves an F1-score of 96.49% for compatibility detection and a repair accuracy of 92.26%, significantly outperforming state-of-the-art approaches including MLCatchUp, Relancer, and GPT-4o. Its effectiveness and practicality are further validated on 30 real-world GitHub projects.
📝 Abstract
In modern software development, Python third-party libraries play a critical role, especially in fields like deep learning and scientific computing. However, API parameters in these libraries often change during evolution, leading to compatibility issues for client applications reliant on specific versions. Python's flexible parameter-passing mechanism further complicates this, as different passing methods can result in different API compatibility. Currently, no tool can automatically detect and repair Python API parameter compatibility issues. To fill this gap, we introduce PCART, the first solution to fully automate the process of API extraction, code instrumentation, API mapping establishment, compatibility assessment, repair, and validation. PCART handles various types of Python API parameter compatibility issues, including parameter addition, removal, renaming, reordering, and the conversion of positional to keyword parameters. To evaluate PCART, we construct PCBENCH, a large-scale benchmark comprising 47,478 test cases mutated from 844 parameter-changed APIs across 33 popular Python libraries. Evaluation results demonstrate that PCART is both effective and efficient, significantly outperforming existing tools (MLCatchUp and Relancer) and the large language model ChatGPT (GPT-4o), achieving an F1-score of 96.49% in detecting API parameter compatibility issues and a repair precision of 92.26%. Further evaluation on 30 real-world Python projects from GitHub confirms PCART's practicality. We believe PCART can significantly reduce the time programmers spend maintaining Python API updates and advance the automation of Python API compatibility issue repair.