-
Notifications
You must be signed in to change notification settings - Fork 2
CPP input in python tutor #1
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if len(sys.argv) > 3: | ||
if sys.argv[3] == '--prettydump': | ||
prettydump = True | ||
thrid_argument_is_input = (sys.argv[3] != '--prettydump') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Change to third_argument_is_input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
prettydump = True | ||
thrid_argument_is_input = (sys.argv[3] != '--prettydump') | ||
if thrid_argument_is_input: | ||
USER_INPUT = sys.argv[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand this well, but are you sending the entire STDIN in a command line argument? This seems inefficient and error-prone. For example, how do you make sure that the contents of the input are not interpreted as a fourth argument when you send it from the command line? IMHO a better approach is saving the input in a file, and sending the file name as a command-line argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Daniel, I also have this concern. However, it is the way that the author did initially with the user code and it also has spaces and special characters. Could you look a this file?https://github.com/JuezUN/OnlinePythonTutor/blob/cpp-input/v4-cokapi/cokapi.js#L243 I assumed this would be safe as the code is also sent via command line and it has a lot of spaces and special characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this input sent from?
This changes allow the "run_cpp_backend.py" script to receive user input as a console parameter and use it as the stdin for the user code under execution.
valgrind debugger redirects stdin all the way to the user program, so, if we redirect the user input parameter into the debugger stdin it will be used as the stdin for the original problem
@0xDCA @larranaga @milderhc
Could you guys take a look at it?