from pathlib import Path
p = Path(r"C:\projects\manual_slop_tier2\tests\test_audit_exception_handling_heuristics.py")
data = p.read_bytes()

# In the test file source (Python source code), the test source string is:
#   '  sys.stderr.write("FATAL: config missing\\n")\n'
# When Python parses this, it becomes the actual string:
#   '  sys.stderr.write("FATAL: config missing\n")\n'  (with real \n in string literal)
# When this is written to a fixture file, the file gets a real newline INSIDE the
# string literal, breaking the syntax.
#
# Fix: change "\\n" to "" (no newline in the message string).
needle = b'  sys.stderr.write("FATAL: config missing\\\\n")\\n'
replacement = b'  sys.stderr.write("FATAL: config missing")\\n'
if needle in data:
    data = data.replace(needle, replacement)
    p.write_bytes(data)
    print("ok: removed \\n from sys.stderr.write message")
else:
    print(f"NOT FOUND; bytes: {needle!r}")
    idx = data.find(b"FATAL")
    if idx > 0:
        print(f"context: {data[idx-20:idx+50]!r}")