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

PR: Fix ValueError when switching Python interpreters #5585

Merged
merged 3 commits into from
Nov 9, 2017

Conversation

csabella
Copy link
Contributor

@csabella csabella commented Oct 27, 2017

Fixes #5402.

In issue #5402, the call to sys.version_info was returning b'' instead of b'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 to programs.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 from warn_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.

@ccordoba12 ccordoba12 changed the base branch from master to 3.x October 27, 2017 01:15
@ccordoba12 ccordoba12 added this to the v3.2.5 milestone Oct 27, 2017
if custom:
self.warn_python_compatibility(cust_pyexec)
if custom and not self.warn_python_compatibility(cust_pyexec):
self.pyexec_edit.setText(def_pyexec)
Copy link
Member

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 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ccordoba12

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.

@ccordoba12
Copy link
Member

Thanks @csabella! This looks good to me, except for my minor comment.

@pep8speaks
Copy link

pep8speaks commented Nov 7, 2017

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

@ccordoba12
Copy link
Member

@csabella, please fix the pep8 issue here.

Copy link
Member

@ccordoba12 ccordoba12 left a 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!

@ccordoba12 ccordoba12 changed the title PR: ValueError when switching Python interpreters PR: Fix ValueError when switching Python interpreters Nov 9, 2017
@ccordoba12 ccordoba12 merged commit 03b1638 into spyder-ide:3.x Nov 9, 2017
ccordoba12 added a commit that referenced this pull request Nov 9, 2017
@csabella csabella deleted the issue5402 branch November 9, 2017 21:29
@csabella csabella mentioned this pull request Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants