Merged
fix(easyasc): use context manager when reading DSL file in check_ub_usage.py #436
liangjinxuan-2026Add on 6 days ago
fix(easyasc): use context manager when reading DSL file in check_ub_usage.py #436
Merged
Total: 1 files changed+2-1
| @@ -161,7 +161,8 @@ def detect_var_tile(dsl_path: str | None) -> Tuple[bool, str]: | |||
| 161 | if not dsl_path: | 161 | if not dsl_path: |
| 162 | return (False, "no --dsl provided") | 162 | return (False, "no --dsl provided") |
| 163 | try: | 163 | try: |
| 164 | - text = open(dsl_path, encoding="utf-8").read() | 164 | + with open(dsl_path, encoding="utf-8") as fp: |
| 165 | + text = fp.read() | ||
| 165 | except OSError: | 166 | except OSError: |
| 166 | return (False, f"could not read DSL file: {dsl_path}") | 167 | return (False, f"could not read DSL file: {dsl_path}") |
| 167 | for pat in _VAR_TILE_PATTERNS: | 168 | for pat in _VAR_TILE_PATTERNS: |
评审通过(代码层):open().read() 改为 with 上下文读取,行为不变、资源释放更确定。CI 流水线尚未触发,合入前建议评论 /compile 触发确认。