Issue1604250

classification
Title: Java descriptors dont allow __doc__ to be set
Type: Severity: normal
Components: Core Versions:
process
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.

Messages
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 test_descr.py 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, "file name") # member descriptor

What's worse is that this explodes in the jython interpreter:
java.lang.NullPointerException
        at org.python.core.PyObject.getDoc(PyObject.java:360)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.python.core.PyGetSetDescr.__get__(PyGetSetDescr.java:55)
        at org.python.core.PyObject.object___findattr__(PyObject.java:2770)
        at org.python.core.PyObject.__findattr__(PyObject.java:1044)
        at org.python.core.PyObject.__getattr__(PyObject.java:1081)
        at org.python.pycode._pyx2.f$0(<console>:1)
        at org.python.pycode._pyx2.call_function(<console>)
        at org.python.core.PyTableCode.call(PyTableCode.java:213)
        at org.python.core.PyCode.call(PyCode.java:14)
        at org.python.core.Py.runCode(Py.java:1182)
        at org.python.core.Py.exec(Py.java:1204)
        at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148)
        at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:88)
        at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:69)
        at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:44)
        at org.python.util.InteractiveConsole.push(InteractiveConsole.java:83)
        at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:62)
        at org.python.util.jython.main(jython.java:214)

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...????

leouser
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
History
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