File tree 3 files changed +26
-4
lines changed
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ Bug Fixes
83
83
84
84
**Other **
85
85
86
- -
86
+ - Fixed AttributeError when printing a DataFrame's HTML repr after accessing the IPython config object ( :issue: ` 25036 `)
87
87
-
88
88
89
89
.. _whatsnew_0.241.contributors :
Original file line number Diff line number Diff line change 17
17
import itertools
18
18
import sys
19
19
import warnings
20
+ from distutils .version import LooseVersion
20
21
from textwrap import dedent
21
22
22
23
import numpy as np
@@ -646,9 +647,15 @@ def _repr_html_(self):
646
647
# XXX: In IPython 3.x and above, the Qt console will not attempt to
647
648
# display HTML, so this check can be removed when support for
648
649
# IPython 2.x is no longer needed.
649
- if console .in_qtconsole ():
650
- # 'HTML output is disabled in QtConsole'
651
- return None
650
+ try :
651
+ import IPython
652
+ except ImportError :
653
+ pass
654
+ else :
655
+ if LooseVersion (IPython .__version__ ) < LooseVersion ('3.0' ):
656
+ if console .in_qtconsole ():
657
+ # 'HTML output is disabled in QtConsole'
658
+ return None
652
659
653
660
if self ._info_repr ():
654
661
buf = StringIO (u ("" ))
Original file line number Diff line number Diff line change 12
12
import os
13
13
import re
14
14
import sys
15
+ import textwrap
15
16
import warnings
16
17
17
18
import dateutil
@@ -2777,3 +2778,17 @@ def test_format_percentiles():
2777
2778
fmt .format_percentiles ([2 , 0.1 , 0.5 ])
2778
2779
with pytest .raises (ValueError , match = msg ):
2779
2780
fmt .format_percentiles ([0.1 , 0.5 , 'a' ])
2781
+
2782
+
2783
+ def test_repr_html_ipython_config (ip ):
2784
+ code = textwrap .dedent ("""\
2785
+ import pandas as pd
2786
+ df = pd.DataFrame({"A": [1, 2]})
2787
+ df._repr_html_()
2788
+
2789
+ cfg = get_ipython().config
2790
+ cfg['IPKernelApp']['parent_appname']
2791
+ df._repr_html_()
2792
+ """ )
2793
+ result = ip .run_cell (code )
2794
+ assert not result .error_in_exec
You can’t perform that action at this time.
0 commit comments