Issue1462188
Created on 2006-03-31.15:42:46 by astoddar, last changed 2006-08-13.01:53:31 by cgroves.
Messages | |||
---|---|---|---|
msg1119 (view) | Author: Alex Stoddard (astoddar) | Date: 2006-03-31.15:42:46 | |
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 the 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 |
|||
msg1120 (view) | Author: Nobody/Anonymous (nobody) | Date: 2006-04-06.08:52:29 | |
Logged In: NO It can be fixed the way that the NPE doesn't occur anymore. But, if there is no documentation string for dict (and BTW, for other built-in types as well), an AttributeError will be thrown. So, what should we do ? Hm, when we look at CPython, we can see that, here too, dict for example has a very poor documentation string. The same applies to list. Maybe we should simply return an empty string. What do others think ? |
|||
msg1121 (view) | Author: andrey sidorenko (gene9) | Date: 2006-04-28.11:13:35 | |
Logged In: YES user_id=369541 > cvs diff PyObject.java Index: PyObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyObject.java,v retrieving revision 2.43 diff -r2.43 PyObject.java 388c388,394 < PyObject doc = fastGetDict().__finditem__("__doc__"); --- > > PyObject dict = fastGetDict(); > if(dict == null) { > return Py.None; > } > > PyObject doc = dict.__finditem__("__doc__"); |
|||
msg1122 (view) | Author: Khalid Zuberi (kzuberi) | Date: 2006-05-15.16:29:18 | |
Logged In: YES user_id=18288 Thanks gene9, that null-guard in PyObject:getDoc() fixes the exception for me. Probably at some point we can also add the docs to dict & friends, copying cpython. - kz |
|||
msg1123 (view) | Author: Charlie Groves (cgroves) | Date: 2006-08-13.01:53:31 | |
Logged In: YES user_id=1174327 Looks like the nullguard from gene9 has already been applied so I'm closing this. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2006-03-31 15:42:46 | astoddar | create |
Supported by Python Software Foundation,
Powered by Roundup