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

Fix consoles encoding in Python 3 #3062

Merged
merged 2 commits into from Mar 14, 2016

Conversation

s-weigand
Copy link
Contributor

Fixes #3061


Here is the fix for the bug described in #3061.
@PierreRaybaut as author if that piece of code should review my change and check if not I broke more than I fixed. :D

best regards Sebastian

@ccordoba12 ccordoba12 changed the title fix issue #3061, review needed by PierreBaybaut fix issue #3061, review needed by Pierre Mar 14, 2016
@PierreRaybaut
Copy link
Contributor

As I wrote in issue #3061, I recommend keeping the "Setting console encoding [...] for Windows platforms" code block for Python 2.

So the right fix for me would rather be the following:

#==============================================================================
# Setting console encoding (otherwise Python does not recognize encoding)
# for Windows platforms
#==============================================================================
+if os.name == 'nt' and PY2:
-if os.name == 'nt':
    try:
        import locale, ctypes
        _t, _cp = locale.getdefaultlocale('LANG')
        try:
            _cp = int(_cp[2:])
            ctypes.windll.kernel32.SetConsoleCP(_cp)
            ctypes.windll.kernel32.SetConsoleOutputCP(_cp)
        except (ValueError, TypeError):
            # Code page number in locale is not valid
            pass
    except ImportError:
        pass

@ccordoba12 ccordoba12 added this to the v3.0beta3 milestone Mar 14, 2016
@ccordoba12 ccordoba12 changed the title fix issue #3061, review needed by Pierre Fix consoles encoding in Python 3 Mar 14, 2016
@ccordoba12
Copy link
Member

@s-weigand, please remove your last commit (we don't accept PRs with blank space changes).

Also, please don't do more commits besides the change suggested by Pierre. If things fail in our continuous integration services, we'll see how to fix them (usually that requires to restart the build, which was what I was doing).

@s-weigand
Copy link
Contributor Author

Sorry it took my so long to remove my last commit,
i started onyl yesterday to use the github-bach and it took me some time to find out what to do to remove a allready pushed commit (rebase and force push).
Also the changed blank spaces weren't intentionally, my spyder is set to delete tailing blank spaces when saving the file.
Noob at work here :D

@ccordoba12
Copy link
Member

Ok, sorry if i sounded too bossy, I thought you knew git and all this stuff :-)

Tests are passing now, so I'm merging your work. Thanks a lot for your contribution!

ccordoba12 added a commit that referenced this pull request Mar 14, 2016
Fix consoles encoding in Python 3
@ccordoba12 ccordoba12 merged commit 90ab905 into spyder-ide:master Mar 14, 2016
@s-weigand s-weigand deleted the fix_issue_3061 branch March 14, 2016 20:13
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.

Different output for internal and external console on Windows
3 participants