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

[2023.11.01_RC3] Syntax errors prevent terminal init #1831

Open
3 tasks done
JoshuaLowe1002 opened this issue Nov 1, 2023 · 2 comments
Open
3 tasks done

[2023.11.01_RC3] Syntax errors prevent terminal init #1831

JoshuaLowe1002 opened this issue Nov 1, 2023 · 2 comments
Labels
3rd party Errors coming from foreign projects we either enable or rely on needs-triage Issue needs triage type: bug Something isn't working

Comments

@JoshuaLowe1002
Copy link
Member

JoshuaLowe1002 commented Nov 1, 2023

Checklist

  • I added a descriptive title
  • I searched for other issues and couldn't find a solution or duplication
  • I already searched in Google and didn't find any good information or help

What happened?

Currently if Pyodide detects a syntax error when it goes to run the initial Python code, it seems that this is not being sent to the terminal (even though these errors are being sent through to stderr on the Pyodide side).

It seems as though the current code to send Stderr/Stdout to the terminal is not working in this scenario.

You can test this by trying to execute the following Python code:

print("Hello)

It does however seem to be a simple fix (by editing py-terminal.js), as I have tried the following and it appears to solve the issue.

I apologise for the hacky code, but just wanted to try and demonstrate a possible fix and let the experts take over 😄

  1. Add this inside hooks.main.onWorker.add
xworker.sync.pyterminal_write_std = (value) => {
    readline.write(value);
};
  1. Change workerReady so that it has access to io
const workerReady = ({ interpreter, io }, { sync }) => {
  1. Add this inside workerReady
io.stdout = (value) => {
    sync.pyterminal_write_std(`${value}\n`);
};
io.stderr = (error) => {
    sync.pyterminal_write_std(`${error.message || error}\n`);
};

Let me know if anything does make sense here or if I can provide any extra context!

What browsers are you seeing the problem on? (if applicable)

No response

Console info

No response

Additional Context

No response

@JoshuaLowe1002 JoshuaLowe1002 added needs-triage Issue needs triage type: bug Something isn't working labels Nov 1, 2023
@JoshuaLowe1002 JoshuaLowe1002 changed the title [RC3] Syntax errors prevent terminal init [2023.11.01_RC3] Syntax errors prevent terminal init Nov 1, 2023
@WebReflection
Copy link
Contributor

I think until pyodide provides a way to catch errors at distance we're still incapable of dealing with these kind of errors because we simply hook into the stderr pyodide provides ... however, we did make some change to the terminal and I wonder if this bug is still valid 🤔

@WebReflection WebReflection added the 3rd party Errors coming from foreign projects we either enable or rely on label Jan 11, 2024
@WebReflection
Copy link
Contributor

is this still anyhow relevant or broken? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party Errors coming from foreign projects we either enable or rely on needs-triage Issue needs triage type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants