-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Fix ValueError when switching Python interpreters #5585
Conversation
spyder/plugins/maininterpreter.py
Outdated
if custom: | ||
self.warn_python_compatibility(cust_pyexec) | ||
if custom and not self.warn_python_compatibility(cust_pyexec): | ||
self.pyexec_edit.setText(def_pyexec) |
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 should show the same warning as above before doing this, i.e.
You selected an invalid Python interpreter for the console so the previous ...
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.
python_executable_changed
and python_executable_switched
had very similar code, especially with the addition of this message. Instead of duplicating the message, I instead changed it to call python_executable_changed
from python_executable_switched
. I hope that's OK.
Thanks @csabella! This looks good to me, except for my minor comment. |
Hello @csabella! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on November 09, 2017 at 13:10 Hours UTC |
@csabella, please fix the pep8 issue here. |
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 @csabella! Great work!
Fixes #5402.
In issue #5402, the call to sys.version_info was returning
b''
instead ofb'3'
. The ValueError was a result of calling int() on an empty bytes value. The change checks for this exception and treats it the same as the call toprograms.is_python_interpreter()
.I don't know why the subprocess call with the program name and -h option would work in
is_python_interpreter()
, but the -c option call fromwarn_python_compatibility
wouldn't returning a valid value. The assumption made was that if the -c option doesn't work, then something else might be wrong with the interpreter, so it switches back to the default.