You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in the formatting of functions belonging to a class in IPython 2.0.0 running in Python3.
In [1]: class A:
...: def f(self):
...: pass
...:
In [2]: A.f
Out[2]: <function __main__.f>
In [3]: str(A.f)
Out[3]: '<function A.f at 0x10b283840>'
The function name formatting is using the __name__ attribute of the function instead of __qualname__, which results in incorrectly showing the function f here in our example belongs to __main__ instead of __main__.A.
def _function_pprint(obj, p, cycle):
"""Base pprint for all functions and builtin functions."""
if obj.__module__ in ('__builtin__', 'builtins', 'exceptions') or not obj.__module__:
name = obj.__name__
else:
name = obj.__module__ + '.' + obj.__name__ # use obj.__qualname__
p.text('<function %s>' % name)
The text was updated successfully, but these errors were encountered:
takluyver
added a commit
to takluyver/ipython
that referenced
this issue
Apr 9, 2014
There is a bug in the formatting of functions belonging to a class in IPython 2.0.0 running in Python3.
The function name formatting is using the
__name__
attribute of the function instead of__qualname__
, which results in incorrectly showing the functionf
here in our example belongs to__main__
instead of__main__.A
.A quick fix would be a one line change in https://github.com/ipython/ipython/blob/master/IPython/lib/pretty.py#L749 to use
__qualname__
instead, but will break in Python 2.x as there is no__qualname__
support.The text was updated successfully, but these errors were encountered: