Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_exist function not removing special characters from response #308

Closed
snheffer opened this issue Nov 10, 2023 · 2 comments
Closed

_exist function not removing special characters from response #308

snheffer opened this issue Nov 10, 2023 · 2 comments

Comments

@snheffer
Copy link

snheffer commented Nov 10, 2023

Hi,

from what I can tell,

def _exist(self, name):
        """
       Test whether a name exists and return the name code.

        Raises an error when the name does not exist.
        """
        if not self._engine:
            msg = "Session is not open"
            raise Oct2PyError(msg)
        resp = self._engine.eval(cmd, silent=True).strip()
        exist = int(resp.split()[-1])

isn't removing some character sequences from the response integer.
e.g. I get "invalid literal for int() with base 10: '\r\n\x1b[?2004h'", when exist should equal 5 with msg equalling "ans = 5", meaning a builtin ("addpath")

which suggests \r\n\x1b[?2004h isnt getting stripped from the string, as I don't think it's getting split properly.
I'm running oct2py on 3.9.

@blink1073
Copy link
Owner

Hi @snheffer, this is a known issue, with a workaround in pexpect: pexpect/pexpect#669 (comment)

@snheffer
Copy link
Author

Thanks for getting back to me so quickly @blink1073 , yes that fixed my issue, it's a interesting quirk I hadn't encountered before with bash!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants