Tweak Inspector.info() so it doesn't fail on old style classes. Added test.
Tweak Inspector.info() so it doesn't fail on old style classes. Added…
You can just do callable_obj = getattr(obj, '__init__', obj). A class object itself is callable.
callable_obj = getattr(obj, '__init__', obj)
It is, but getargspec won't handle a class.
Interesting, because I made exactly this change and it works just fine.
correctly shows 'doc' in the tooltip.
The bit that gets the docstring is working already, this is just an incidental error in Inspector.info() with old-style classes. I've just checked, and we catch the error from getargspec, so the result will be the same. I went for catching AttributeError because it's a pattern that's used several times already in the info method.
Fair enough. I still like getattr(obj, '__init__', None) better than 4 lines, but that's not important. I say merge.
getattr(obj, '__init__', None)
Actually, yes. While we're here, let's make it tidy...
I wish to preemptively apologize for this and future things I will break in iPython. By mid-July, I expect I will know the code base well enough to start pitching in.
Thanks guys :)
Neater code using getattr, as suggested by MinRK.
@meawoppl: Don't worry - you didn't break it, you just found that it was already broken. We like people to find bugs before release. Especially when they're easily fixed, like this one.
Waiting an hour or so for any objections, then we'll merge, since it's a small fix.