File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ Bug Fixes
8383
8484**Other **
8585
86- -
86+ - Fixed AttributeError when printing a DataFrame's HTML repr after accessing the IPython config object ( :issue: ` 25036 `)
8787-
8888
8989.. _whatsnew_0.241.contributors :
Original file line number Diff line number Diff line change 1717import itertools
1818import sys
1919import warnings
20+ from distutils .version import LooseVersion
2021from textwrap import dedent
2122
2223import numpy as np
@@ -646,9 +647,15 @@ def _repr_html_(self):
646647 # XXX: In IPython 3.x and above, the Qt console will not attempt to
647648 # display HTML, so this check can be removed when support for
648649 # 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
652659
653660 if self ._info_repr ():
654661 buf = StringIO (u ("" ))
Original file line number Diff line number Diff line change 1212import os
1313import re
1414import sys
15+ import textwrap
1516import warnings
1617
1718import dateutil
@@ -2777,3 +2778,17 @@ def test_format_percentiles():
27772778 fmt .format_percentiles ([2 , 0.1 , 0.5 ])
27782779 with pytest .raises (ValueError , match = msg ):
27792780 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