From 28f338c715b17072d8129a6bbfd14dbaa3b8aa4d Mon Sep 17 00:00:00 2001 From: s-weigand Date: Sun, 13 Mar 2016 22:21:29 +0100 Subject: [PATCH 1/2] fixes issue #3061, review needed by PierreBaybaut --- .../widgets/externalshell/sitecustomize.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/spyderlib/widgets/externalshell/sitecustomize.py b/spyderlib/widgets/externalshell/sitecustomize.py index e381ab3d77b..7846eb22505 100644 --- a/spyderlib/widgets/externalshell/sitecustomize.py +++ b/spyderlib/widgets/externalshell/sitecustomize.py @@ -146,25 +146,6 @@ def write(self, text): os.environ['SPYDER_PARENT_DIR'] = spyderlib_path -#============================================================================== -# Setting console encoding (otherwise Python does not recognize encoding) -# for Windows platforms -#============================================================================== -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 - - #============================================================================== # Settings for our MacOs X app #============================================================================== From 857446bb46190ad7ea64c460b6cbd71680cd79ef Mon Sep 17 00:00:00 2001 From: s-weigand Date: Mon, 14 Mar 2016 16:36:12 +0100 Subject: [PATCH 2/2] fix for #3061, only for PY3 as requested --- .../widgets/externalshell/sitecustomize.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spyderlib/widgets/externalshell/sitecustomize.py b/spyderlib/widgets/externalshell/sitecustomize.py index 7846eb22505..09b4c32fda4 100644 --- a/spyderlib/widgets/externalshell/sitecustomize.py +++ b/spyderlib/widgets/externalshell/sitecustomize.py @@ -146,6 +146,25 @@ def write(self, text): os.environ['SPYDER_PARENT_DIR'] = spyderlib_path +#============================================================================== +# Setting console encoding (otherwise Python does not recognize encoding) +# for Windows platforms +#============================================================================== +if os.name == 'nt' and PY2: + 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 + + #============================================================================== # Settings for our MacOs X app #==============================================================================