File tree 1 file changed +10
-2
lines changed 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,9 @@ def _encode_diff_func():
165
165
encoding = get_option ("display.encoding" )
166
166
167
167
def _encode_diff (x ):
168
- return len (x ) - len (x .decode (encoding ))
168
+ if not isinstance (x ,unicode ):
169
+ return len (x ) - len (x .decode (encoding ))
170
+ return 0
169
171
170
172
return _encode_diff
171
173
@@ -1639,13 +1641,14 @@ def reset_printoptions():
1639
1641
FutureWarning )
1640
1642
reset_option ("^display\." )
1641
1643
1642
-
1644
+ _initial_defencoding = None
1643
1645
def detect_console_encoding ():
1644
1646
"""
1645
1647
Try to find the most capable encoding supported by the console.
1646
1648
slighly modified from the way IPython handles the same issue.
1647
1649
"""
1648
1650
import locale
1651
+ global _initial_defencoding
1649
1652
1650
1653
encoding = None
1651
1654
try :
@@ -1662,6 +1665,11 @@ def detect_console_encoding():
1662
1665
if not encoding or 'ascii' in encoding .lower (): # when all else fails. this will usually be "ascii"
1663
1666
encoding = sys .getdefaultencoding ()
1664
1667
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
+
1665
1673
return encoding
1666
1674
1667
1675
You can’t perform that action at this time.
0 commit comments