From: SourceForge.net <no...@so...> - 2006-04-28 11:13:43
|
Bugs item #1462188, was opened at 2006-03-31 18:42 Message generated for change (Comment added) made by gene9 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1462188&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Alex Stoddard (astoddar) Assigned to: Nobody/Anonymous (nobody) Summary: NullPointerException on accessing __doc__ attribute Initial Comment: 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 ---------------------------------------------------------------------- Comment By: andrey sidorenko (gene9) Date: 2006-04-28 14:13 Message: 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__"); ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-04-06 11:52 Message: 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 ? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1462188&group_id=12867 |