Skip to content

Commit 44a400d

Browse files
author
y-p
committed
ENH: save initial sys.getdefaultencoding() value aside for debugging
1 parent 439316f commit 44a400d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/core/format.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,13 +1641,14 @@ def reset_printoptions():
16411641
FutureWarning)
16421642
reset_option("^display\.")
16431643

1644-
1644+
_initial_defencoding = None
16451645
def detect_console_encoding():
16461646
"""
16471647
Try to find the most capable encoding supported by the console.
16481648
slighly modified from the way IPython handles the same issue.
16491649
"""
16501650
import locale
1651+
global _initial_defencoding
16511652

16521653
encoding = None
16531654
try:
@@ -1664,6 +1665,11 @@ def detect_console_encoding():
16641665
if not encoding or 'ascii' in encoding.lower(): # when all else fails. this will usually be "ascii"
16651666
encoding = sys.getdefaultencoding()
16661667

1668+
# GH3360, save the reported defencoding at import time
1669+
# MPL backends may change it. Make available for debugging.
1670+
if not _initial_defencoding:
1671+
_initial_defencoding = sys.getdefaultencoding()
1672+
16671673
return encoding
16681674

16691675

0 commit comments

Comments
 (0)