-
Notifications
You must be signed in to change notification settings - Fork 67
Do eval and exec for repl evaluate requests #218
Conversation
I'll have to check how this works with VSC as well. That because when evaluating expressions in the VSC debug console Just out of curiosity, what happens if we enter an invalid variable or expression, such as |
Yep the error will be printed to the output. |
result = unquote(xvar2['value']) | ||
except: | ||
# if resp_args is not xml then it contains the error traceback | ||
result_type = unquote(xvar['type']) |
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.
If we're sending the traceback, then we need to filter the traceback to hide the internals.
Currently we're sending too much (internal) information back to the user. I would have thought just the error message would suffice. what's the current behaviour in VS. In VSC we just display the error message.
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.
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.
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 had a similar idea (when using CMD_CONSOLE_EXEC
) but that's where I got stuck this evening. Gets complicated when you evaluate a function that starts a thread which prints stuff (sounds too far fetched).
Anyways, would like to see how it is that the stack trace isn't printed for your code, but only for VSC. Is it because you're ignoring what comes from output
event?
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.
The traceback is printed in the console output, in the REPL window we print what is returned via the protocol. the screen sot was from the REPL window.
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.
In REPL scenarios, everything that normally goes into stdout/err is supposed to go to REPL - it just isn't wired yet. But once we do, we will have that problem.
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.
-
Whey aren't we using
CMD_CONSOLE_EXEC
command, after all the value forcontext
isrepl
-
it just isn't wired yet. But once we do, we will have that problem.
- I think I understand, VSC is getting the
stdout/stderr
messages via the protocol as VSC is passing in the valuetrue
for the setting redirectOutput. I'm assuming VS doesn't use this.
- I think I understand, VSC is getting the
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 will give CMD_CONSOLE_EXEC a try in the morning, and update this PR if it seems better.
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.
CMD_CONSOLE_EXEC does not work the way we want it. For the following REPL statements, this is the result we get:
In REPL window:
>>> random.random()
False
>>> import random
False
>>> random.random()
False
>>>
In Console Window:
Traceback (most recent call last):
File "c:\git\ptvsd\ptvsd\pydevd\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<input>", line 1, in <module>
NameError: name 'random' is not defined
<xml><var name="" type="bool" qualifier="builtins" value="False" />
</xml>
<xml><var name="" type="bool" qualifier="builtins" value="False" />
</xml>
0.9210117288960727
<xml><var name="" type="bool" qualifier="builtins" value="False" />
</xml>
XML response received from pydevd:
>>> random.random()
<xml><var name="" type="bool" qualifier="builtins" value="False" />
</xml>
>>> import random
<xml><var name="" type="bool" qualifier="builtins" value="False" />
</xml>
>>> random.random()
<xml><var name="" type="bool" qualifier="builtins" value="False" />
</xml>
As you can see it always return false.
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.
All good at my end 👍
This change is part of the debug REPL changes needed for VS