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

return value of InteractiveShell.run_cell and run_ast_nodes #7256

Closed
rainwoodman opened this issue Dec 17, 2014 · 3 comments · Fixed by #7262 · May be fixed by #14197
Closed

return value of InteractiveShell.run_cell and run_ast_nodes #7256

rainwoodman opened this issue Dec 17, 2014 · 3 comments · Fixed by #7262 · May be fixed by #14197
Assignees
Milestone

Comments

@rainwoodman
Copy link

the (undocumented) return value of InteractiveShell.run_ast_nodes is

  • True on succesful execution,
  • False on failed execution,
  • None on no execution

the return value of run_cell is always None. This is asymmetric.

@takluyver
Copy link
Member

Are you doing something where some return value from run_cell would be useful? I don't think these methods automatically need symmetry; they take very different arguments as well.

@rainwoodman
Copy link
Author

Yes there is a use.

The isolate magic shells out the content of the cell to run_cell (to allow other ipython transforms) .
Without a return value from run_cell there is no way to tell if the execution has failed or not.
Idealy, on a failed execution we shall skip asserting the existence of post execution variable names.

takluyver added a commit to takluyver/ipython that referenced this issue Dec 17, 2014
code ran successfully. I discussed this with Min, who suggested that
given the complexity of run_cell, it should return a result object that
can store different pieces of information about what happened.

This currently stores `execution_count`, `error_before_exec` (i.e.
errors transforming, parsing or compiling the code), `error_in_exec` and
`result`. It calculates `success` as a boolean that's true if neither of
the error fields are set.

Closes ipythongh-7256
takluyver added a commit to takluyver/ipython that referenced this issue Dec 17, 2014
ipythongh-7256 asked for a boolean return value from run_cell() for whether
code ran successfully. I discussed this with Min, who suggested that
given the complexity of run_cell, it should return a result object that
can store different pieces of information about what happened.

This currently stores `execution_count`, `error_before_exec` (i.e.
errors transforming, parsing or compiling the code), `error_in_exec` and
`result`. It calculates `success` as a boolean that's true if neither of
the error fields are set.

Closes ipythongh-7256
@takluyver
Copy link
Member

OK, that makes sense. @minrk suggested that an object with several fields might be better than a single boolean, since there's quite a lot going on in run_cell. I have implemented this in #7262.

@minrk minrk added this to the 3.0 milestone Jan 30, 2015
idanpa added a commit to idanpa/ipython that referenced this issue Oct 1, 2023
the raw_cell might need transformation and cannot be tokenized.
Fixes ipython#7256
idanpa added a commit to idanpa/ipython that referenced this issue Oct 1, 2023
the raw_cell might need transformation and cannot be tokenized.
Fixes ipython#7256
idanpa added a commit to idanpa/ipython that referenced this issue Oct 1, 2023
the raw_cell might need transformation and cannot be tokenized.
Fixes ipython#7256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants