Skip to content

Error on CSI sequence with "'" in the Intermediate bytes #192

@Floris497

Description

@Floris497

So I am using pyte to connect to an OpenVMS terminal and this sequence of bytes causes a problem (when opening the text editor)

This is a small preview of the data that causes an issue for me, and how to reproduce the error

import pyte
screen = pyte.Screen(80, 24)
stream = pyte.ByteStream()
stream.use_utf8 = False
stream.attach(screen)
stream.feed(bytes.fromhex("0d0a1b5c9b306d9b32306c1b29300f1b2a3c1b7d9b6d9b324a9b3f336c9b3b3234729b346c1b3d9b3f366c9b3f376c9b4d9b313b32277a9b313b33277b9b32343b489b4a9b4b9b32313b3830481b5b314a9b3b485b456e64206f662066696c655d9b4b9b3232"))

Causes the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.11/site-packages/pyte/streams.py", line 424, in feed
    super(ByteStream, self).feed(data_str)
  File "/opt/homebrew/lib/python3.11/site-packages/pyte/streams.py", line 205, in feed
    taking_plain_text = send(data[offset:offset + 1])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pyte/streams.py", line 213, in _send_to_parser
    return self._parser.send(data)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pyte/streams.py", line 355, in _parser_fsm
    csi_dispatch[char](*params)
TypeError: Screen.cursor_to_column() takes from 1 to 2 positional arguments but 3 were given

With the help of ChatGPT I was able to understand that there are ' in the CSI sequence
for instance: "1;3'{"
but I cannot find out why they are there. does anyone have an idea and maybe a way to solve this nicely?

I copied this code and replaced "$" with "'" and that does prevent the error from showing. but I do not really understand if that just ignores the whole sequence?

pyte/pyte/streams.py

Lines 341 to 345 in 636b679

elif char == "$":
# XTerm-specific ESC]...$[a-z] sequences are not
# currently supported.
yield None
break

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions