(m: re.Match)
| 255 | ) |
| 256 | |
| 257 | def decode_hex(m: re.Match) -> str: |
| 258 | content = m.group(1) or m.group(2) |
| 259 | try: |
| 260 | hex_bytes = bytes.fromhex(content.replace('\\x', '')) |
| 261 | decoded = hex_bytes.decode('utf-8', errors='replace') |
| 262 | # Only inline if result is clean ASCII — never put non-ASCII into source |
| 263 | if '\ufffd' not in decoded and decoded.isascii(): |
| 264 | return repr(decoded) |
| 265 | except Exception: |
| 266 | pass |
| 267 | return m.group(0) |
| 268 | |
| 269 | return pattern.sub(decode_hex, source) |
| 270 |
nothing calls this directly
no outgoing calls
no test coverage detected