formachines / errata

Errata / PyPI / websockets

OP_TEXT removed in websockets 17.3

In our sandbox runs up to 2026-10-27, gpt-6.1-sol wrote from websockets.frames import Frame, OP_TEXT for websockets. It fails on 17.3 with ImportError (changed between 16.0 and 17.3). Use from websockets.frames import Frame, TEXT as OP_TEXT instead.

What to do
replace the line
Output
same on one example
Patch
applies word for word
Auto-apply
allowed
Seen in
1 model
Worked / failed
3 / 0
Last verified
2026-10-27

What to do

Replace the old line with the new one; the rest of the code can stay.

Automatic application: allowed — proof.equivalent is true and the patch applies word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (removed); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Old and new code

from websockets.frames import Frame, OP_TEXT
from websockets.frames import Frame, TEXT as OP_TEXT

Error on 17.3:

ImportError: cannot import name 'OP_TEXT' from 'websockets.frames' (/usr/local/lib/python3.11/site-packages/websockets/frames.py)

Other verified fixes

The fix above passed 2 times. These also passed in the sandbox for the same error; pick the one that matches what your code needs.

Replace the line · passed 1 time · gpt-6.1-sol · patch: incomplete: old names remain

from websockets.frames import Frame, OP_TEXT
from websockets.frames import Frame, TEXT

Not for automatic application — after the patch the example still uses OP_TEXT, which the verified example does not: the patch covers part of the change. Show this correction to the user as a lead. Replace the old line with the new one; the rest of the code can stay.

Alternatives are leads for the user, not for automatic application: Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own.

Sandbox proof
Scriptwebsockets versionResult
Code the models wrote16.0works
Code the models wrote17.3fails: ImportError
Verified example below17.3works
Output of the verified example17.3same as the original's on 16.0 (observed stdout of one example; not a proof of equivalent behaviour)
Patch applied word for word to the example17.3applied word for word, the patch parses, runs and prints what the verified example prints

Verified example for websockets 17.3

from io import BytesIO

from websockets.frames import Frame, TEXT as OP_TEXT


def read_exact(size):
    """Generator-based reader required by Frame.parse()."""
    data = yield size
    if len(data) != size:
        raise EOFError("Incomplete frame")
    return data


def main():
    frame = Frame(OP_TEXT, b"hello", fin=True)
    raw = frame.serialize(mask=False)
    print(raw.hex())

    stream = BytesIO(raw)
    parser = Frame.parse(read_exact, mask=False)

    try:
        size = next(parser)
        while True:
            size = parser.send(stream.read(size))
    except StopIteration as result:
        parsed = result.value

    print("Opcode:", parsed.opcode)
    print("Payload:", parsed.data.decode("utf-8"))


if __name__ == "__main__":
    main()

Source

Aliases for modules moved or deprecated in 9.0 are removed.

Release notes · Seen in: gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for websockets

For agents