[IPython-dev] [Fwd: [afayolle at debian.org: Bug#374625: python2.3-ipython: help built-in function does not work]]
fperez.net at gmail.com
Wed Aug 9 03:50:50 EDT 2006
On 8/9/06, Fernando Perez <Fernando.Perez at colorado.edu> wrote:
> I've had over the years, no end of trouble with the inspect module in
> python2.3, it's buggy as all hell. But since we won't get py23 fixed, perhaps
> we can find a solution in the meantime. I see a few options:
> 1. Since the problem happens (as far as I can see) only once, we can hack
> things. Instead of having help() be site._Helper(), we make it a light
> wrapper which discards first-invocation exceptions (with a warning). This is
> very, very inelegant, but can be done in a few minutes and will be isolated to
> python 2.3. The patch would be small, and hence easy to apply for the ipython
> maintainers, who won't be moving to our current SVN wholesale.
> 2. We dig deep enough to understand the real problem and find a cleaner
> workaround. It's not impossible that in this case inspect.py is not the
> problem but our own code.
Well, there's always
3. Steal the fix from python2.4 and monkeypatch 2.3's inspect. This
gives us a time machine-type fix for users of 2.3.
Attached is a patch to do precisely this, which hopefully the Debian
gang can use. The differences between the monkeypatched function in
2.3 and 2.4 are very small (but critical for us), so I'm not too
worried about this creating any hidden bugs. Here's the relevant part
of the diff for the curious:
--- /usr/lib/python2.3/inspect.py 2006-02-02 13:45:16.000000000 -0700
+++ /usr/lib/python2.4/inspect.py 2006-04-27 09:28:08.000000000 -0600
@@ -369,7 +369,7 @@
"""Return the module an object was defined in, or None if not found."""
- if isclass(object):
+ if hasattr(object, '__module__'):
file = getabsfile(object)
@@ -379,7 +379,9 @@
for module in sys.modules.values():
if hasattr(module, '__file__'):
- modulesbyfile[getabsfile(module)] = module.__name__
+ getabsfile(module))] = module.__name__
if file in modulesbyfile:
main = sys.modules['__main__']
I'm committing this in as a fix in trunk, and hopefully it will also
be enough for the Debian team. Please let me know if it either
doesn't fix this particular problem, or if it causes new ones.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2193 bytes
Desc: not available
More information about the IPython-dev