__doc__ attribute bug

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

__doc__ attribute bug

Alexander Stoddard
I have submitted a bug report as follows below. One curious subtlety is
that attempting to duplicate the bug on my own defined classes doesn't
fail, including if i subclass a builtin.

Many thanks again for the great software,

Alex Stoddard


Bug report:

Under jython 2.2 (latest and previous build) attempting to access
specifically the __doc__ attribute of objects of built in classes fails.
The example uses "dict" but the bug is not specific to this.

Other classes may also be affected. The behavior was first seen
introspecting  on an object of the PatternObject class in the re
module.

E.g.

 >>> d = dict()
 >>> dir(d)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__',
'__doc__', '__eq__', '__getattribute__', '__getitem__', '__hash__',
'__init__',
'__iter__', '__len__', '__ne__', '__new__', '__repr__', '__setattr__',
'__setitem__', '__str__', '__unicode__', 'clear', 'copy', 'fromkeys',
'get',
'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys',
'pop',
'popitem', 'setdefault', 'update', 'values']
 >>> d.__class__
<type 'dict'>
 >>> d.__doc__
Traceback (innermost last):
File "<console>", line 1, in ?
java.lang.NullPointerException
at org.python.core.PyObject.getDoc(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
pl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
cessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.python.core.PyGetSetDescr.__get__(Unknown Source)
at org.python.core.PyObject.object___findattr__(Unknown Source)
at org.python.core.PyObject.__findattr__(Unknown Source)
at org.python.core.PyObject.__getattr__(Unknown Source)
at org.python.pycode._pyx11.f$0(<console>:1)
at org.python.pycode._pyx11.call_function(<console>)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyCode.call(Unknown Source)
at org.python.core.Py.runCode(Unknown Source)
at org.python.core.Py.exec(Unknown Source)
at org.python.util.PythonInterpreter.exec(Unknown Source)
at org.python.util.InteractiveInterpreter.runcode(Unknown Source)
at org.python.util.InteractiveInterpreter.runsource(Unknown
Source)
at org.python.util.InteractiveInterpreter.runsource(Unknown
Source)
at org.python.util.InteractiveConsole.push(Unknown Source)
at org.python.util.InteractiveConsole.interact(Unknown Source)
at org.python.util.jython.main(Unknown Source)

java.lang.NullPointerException: java.lang.NullPointerException



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev
Reply | Threaded
Open this post in threaded view
|

Re: __doc__ attribute bug

Khalid Zuberi
On 3/31/06, Alexander Stoddard <[hidden email]> wrote:
>
> Bug report:
>
> Under jython 2.2 (latest and previous build) attempting to access
> specifically the __doc__ attribute of objects of built in classes fails.
> The example uses "dict" but the bug is not specific to this.
>

I have a only a shallow understanding of internals (to say the
least!), but i wonder if something as simple as just setting the
doc-strings in the built-in classes is enough. Eg adding this to
PyDictionary.java:

        dict.__setitem__("__doc__",new PyString("the doc string from cpython"));

Seems to do the expected thing.

- kz


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Jython-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-dev