xeus-python
xeus-python copied to clipboard
XPython Raw repr html fails for `pandas.DataFrame`
Just heads up from testing a PR on JupyterLab with "XPython Raw", which fails on representation of pandas.DataFrame class (instances work, classes fail with):
TypeError: _repr_html_() missing 1 required positional argument: 'self'
Observed:

Expected (in both IPython and normal XPython):

Sorry about the noise if you already fixed that in the master!
Thank you for reporting. I don't think we noticed this one before.
The fix should be for xeus-python-raw to do the same thing as IPython's get_real_method to get the repr method instead of simply checking with has_attr.
Make a pybind11 version of
def get_real_method(obj, name):
"""Like getattr, but with a few extra sanity checks:
- If obj is a class, ignore everything except class methods
- Check if obj is a proxy that claims to have all attributes
- Catch attribute access failing with any exception
- Check that the attribute is a callable object
Returns the method or None.
"""
try:
canary = getattr(obj, '_ipython_canary_method_should_not_exist_', None)
except Exception:
return None
if canary is not None:
# It claimed to have an attribute it should never have
return None
try:
m = getattr(obj, name, None)
except Exception:
return None
if inspect.isclass(obj) and not isinstance(m, types.MethodType):
return None
if callable(m):
return m
return None