-
-
Notifications
You must be signed in to change notification settings - Fork 40
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 globals #308
fix globals #308
Conversation
@impact27, I think the failures in our tests are related to this: ipython/ipykernel#736 |
main_mod = ipython_shell.new_main_mod( | ||
self.filename, '__main__') | ||
self.ns_globals = main_mod.__dict__ | ||
if shell_namespace is global_namespace: |
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.
How efficient is this comparison when there are thousands of variables in the namespace?
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 think the number of variables doesn’t impact the comparison speed, my understanding is that you are just checking if the pointers are the same.
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.
Ok, good to know.
self._saved_globals = shell_namespace.copy() | ||
# Here we clear all variables, let's hope ipykernel | ||
# is not too mad | ||
shell_namespace.clear() |
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.
IPython saves several hidden variables that don't come from running code. This could break that.
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.
Yes but there shouldn’t be any ipython code running between enter and exit. All the code runs in the same thread does it not? I agree that this is a risk
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.
Yes but there shouldn’t be any ipython code running between enter and exit. All the code runs in the same thread does it not?
Yeah, I think so.
I agree that this is a risk
Have you tested this for a while to see if it introduces problems?
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 think we need to call get_ipython().init_user_ns
after clearing the namespace to add the hidden variables back.
I am not confident enough about not introducing a bug with that one. |
Fixes spyder-ide/spyder#16201