PCART  v1.4
Automated Repair of Python API Parameter Compatibility Issues
Functions
patch Namespace Reference

Generate repair patches without rewriting the source AST. More...

Functions

def applyEdits (sourceBytes, edits)
 Apply non-overlapping edits using UTF-8 byte offsets from the original AST 根据原始AST的UTF-8字节位置应用不重叠的修复 More...
 
def makePatchEdit (record, fixedAPI, repairStatus)
 Collect one unambiguous repair result with its original source span 收集唯一修复表达式及其原始源码范围 More...
 
def writeRepairArtifacts (projPath, projName, edits, reportDir)
 Write independent category patches and a Successful-only project copy 写出三类独立补丁及仅含Successful修复的项目副本 More...
 

Detailed Description

Generate repair patches without rewriting the source AST.

Uses existing callsite spans and repair results to generate independent Successful/Unknown/Failed patches. Only Successful edits enter the copied project; original files and source bytes outside edited spans stay unchanged. 使用已有调用点范围和修复结果生成三类独立补丁,仅将Successful修复写入 项目副本,不修改原项目,保留替换范围之外的原始源码字节。

Function Documentation

◆ applyEdits()

def patch.applyEdits (   sourceBytes,
  edits 
)

Apply non-overlapping edits using UTF-8 byte offsets from the original AST 根据原始AST的UTF-8字节位置应用不重叠的修复

Unsafe edits are skipped and logged; a syntax-invalid file is not emitted. 不安全的修复跳过并记录日志,合并后语法无效的文件不输出。

Parameters
sourceBytesOriginal UTF-8 source file bytes, optionally with BOM
editsList of edit dictionaries for this source file
Returns
(modifiedBytes,errorList)

Definition at line 58 of file patch.py.

Here is the caller graph for this function:

◆ makePatchEdit()

def patch.makePatchEdit (   record,
  fixedAPI,
  repairStatus 
)

Collect one unambiguous repair result with its original source span 收集唯一修复表达式及其原始源码范围

Parameters
recordStructured callsite record with original call text and source span
fixedAPIFixed API call expression returned by repairTask
repairStatusRepair status: Successful, Unknown, or Failed
Returns
An edit dictionary, or None for ambiguous/empty/unchanged results

Definition at line 29 of file patch.py.

Here is the caller graph for this function:

◆ writeRepairArtifacts()

def patch.writeRepairArtifacts (   projPath,
  projName,
  edits,
  reportDir 
)

Write independent category patches and a Successful-only project copy 写出三类独立补丁及仅含Successful修复的项目副本

Every category is compared with the original project, not another category. 各类别均与原项目比较,不在其他类别补丁上叠加。

Parameters
projPathOriginal project root path
projNameProject directory name used in fixed_project output
editsList of collected edit dictionaries from all project files
reportDirInternal report directory for the current run command
Returns
Error messages to append to the existing repair log

Definition at line 138 of file patch.py.

Here is the call graph for this function:
Here is the caller graph for this function: