[Numpy-discussion] Is this a small bug in numpydoc?

2010-04-14 Thread Fernando Perez
Howdy,

in ipython we use numpydoc, and as I was just trying to build the docs
from a clean checkout of ipython's trunk, I kept getting errors that I
was able to fix with this patch:

amirbar[sphinxext] svn diff
Index: numpydoc.py
===
--- numpydoc.py (revision 8332)
+++ numpydoc.py (working copy)
@@ -73,7 +73,8 @@
 def mangle_signature(app, what, name, obj, options, sig, retann):
 # Do not try to inspect classes that don't define `__init__`
 if (inspect.isclass(obj) and
-'initializes x; see ' in pydoc.getdoc(obj.__init__)):
+(not hasattr(obj, '__init__') or
+'initializes x; see ' in pydoc.getdoc(obj.__init__))):
 return '', ''

 if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return


The errors were always of the type:

Exception occurred:
  File /home/fperez/ipython/repo/trunk-lp/docs/sphinxext/numpydoc.py,
line 71, in mangle_signature
'initializes x; see ' in pydoc.getdoc(obj.__init__)):
AttributeError: class Bunch has no attribute '__init__'
The full traceback has been saved in /tmp/sphinx-err-H1VlaY.log, if
you want to report the issue to the developers.

so it seems indeed that accessing __init__ without checking it's there
isn't a very good idea.

But I didn't write numpydoc and I'm tired, so I don't want to commit
this without a second pair of eyes...

Cheers,

f
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Is this a small bug in numpydoc?

2010-04-14 Thread Pauli Virtanen
Wed, 14 Apr 2010 01:17:37 -0700, Fernando Perez wrote:
[clip]
 Exception occurred:
   File /home/fperez/ipython/repo/trunk-lp/docs/sphinxext/numpydoc.py,
 line 71, in mangle_signature
 'initializes x; see ' in pydoc.getdoc(obj.__init__)):
 AttributeError: class Bunch has no attribute '__init__' The full
 traceback has been saved in /tmp/sphinx-err-H1VlaY.log, if you want to
 report the issue to the developers.
 
 so it seems indeed that accessing __init__ without checking it's there
 isn't a very good idea.
 
 But I didn't write numpydoc and I'm tired, so I don't want to commit
 this without a second pair of eyes...

Yeah, it's a bug, I think.

-- 
Pauli Virtanen

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Is this a small bug in numpydoc?

2010-04-14 Thread Fernando Perez
On Wed, Apr 14, 2010 at 3:21 AM, Pauli Virtanen pav...@iki.fi wrote:
 But I didn't write numpydoc and I'm tired, so I don't want to commit
 this without a second pair of eyes...

 Yeah, it's a bug, I think.


Thanks, fixed in r8333.

Cheers,

f
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion