Title: Java descriptors dont allow __doc__ to be set
Type: Severity: normal
Components: Core Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, fwierzbicki, kzuberi, leouserz, pjenvey
Priority: normal Keywords:

Created on 2006-11-28.05:16:11 by cgroves, last changed 2009-10-27.07:20:19 by pjenvey.

msg1309 (view) Author: Charlie Groves (cgroves) Date: 2006-11-28.05:16:11
the descriptors created in typeSetup by the templating system don't allow docstrings to be associated with them.  This causes descrdoc in to fail.  Correcting this would require something like

* adding to the method parsing in the templating system to extract doc strings
* passing the docstring to the descriptor constructor in the generated code
* overriding getDoc in PyDescriptor and returning the value passed into the constructor
msg1310 (view) Author: Deleted User leouserz (leouserz) Date: 2007-01-15.14:20:25
The code in question is:
def vereq(a, b):

    if not (a == b):

        raise TestFailed, "%r == %r" % (a, b)

def descrdoc():
    if verbose: print "Testing descriptor doc strings..."
    def check(descr, what):
        vereq(descr.__doc__, what)
    check(file.closed, "True if the file is closed") # getset descriptor
    check(, "file name") # member descriptor

What's worse is that this explodes in the jython interpreter:
        at org.python.core.PyObject.getDoc(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.python.core.PyGetSetDescr.__get__(
        at org.python.core.PyObject.object___findattr__(
        at org.python.core.PyObject.__findattr__(
        at org.python.core.PyObject.__getattr__(
        at org.python.pycode._pyx2.f$0(<console>:1)
        at org.python.pycode._pyx2.call_function(<console>)
        at org.python.core.Py.runCode(
        at org.python.core.Py.exec(
        at org.python.util.PythonInterpreter.exec(
        at org.python.util.InteractiveInterpreter.runcode(
        at org.python.util.InteractiveInterpreter.runsource(
        at org.python.util.InteractiveInterpreter.runsource(
        at org.python.util.InteractiveConsole.push(
        at org.python.util.InteractiveConsole.interact(
        at org.python.util.jython.main(

As to the description as to what to do about getting the __doc__ strings, it appears to make sense.  There just isn't any __doc__ strings that I can see that are in the PyFile class. :(
msg1311 (view) Author: Khalid Zuberi (kzuberi) Date: 2007-01-15.21:10:42
What version of jython were you testing on? While your test snippet fails for me, it does so without the NullPointerException (both on trunk & 2.3, fix from bug 1462188). 

- kz
msg1312 (view) Author: Deleted User leouserz (leouserz) Date: 2007-01-15.21:26:41
Well, now its bombing without the NullPointerException.  I sometimes have experimental jythons floating around so maybe that was the problem...????

msg5270 (view) Author: Philip Jenvey (pjenvey) Date: 2009-10-27.07:20:18
We've gained the ability to doc types, then methods, and now finally 
fields, which lets us pass test_descr.descrdoc now
Date User Action Args
2009-10-27 07:20:19pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5270
nosy: + pjenvey
2009-03-03 17:55:31fwierzbickisetnosy: + fwierzbicki
2006-11-28 05:16:11cgrovescreate