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

Fix Shell on Python 3 #55

Merged
merged 6 commits into from
Oct 1, 2023
Merged

Fix Shell on Python 3 #55

merged 6 commits into from
Oct 1, 2023

Conversation

smarr
Copy link
Member

@smarr smarr commented Oct 1, 2023

As reported by @naomiGrew, the shell on Python 3 had issues with type confusion for the reading/writing to the terminal.

It resulted in an endless loop of the following output:

TypeError: a bytes-like object is required, not 'str'
Caught exception: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/Users/smarr/Projects/SOM/PySOM/src/som/vm/shell.py", line 23, in start
    stmt = raw_input("---> ")
           ^^^^^^^^^^^^^^^^^^
  File "/Users/smarr/Projects/SOM/PySOM/src/rlib/osext.py", line 33, in raw_input
    os.write(1, msg)
TypeError: a bytes-like object is required, not 'str'

This PR fixes it, and also adds special handling for ParseErrors and Exit in the shell to avoid printing the traceback for them.

/cc @naomiGrew @OctaveLarose

os.read() returns a byte buffer, which needs to be converted to a string.
and os.write() expects a byte buffer for output, too.
@smarr smarr merged commit b7acae5 into SOM-st:master Oct 1, 2023
4 checks passed
@smarr smarr deleted the shell branch October 1, 2023 20:25
This pull request was closed.
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

Successfully merging this pull request may close these issues.

1 participant