Issue654142

classification
Title: NPE when converting __dict__ to list
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bzimmer Nosy List: bzimmer, kzuberi, leouserz, pjenvey, reinouts
Priority: low Keywords:

Created on 2002-12-15.17:33:03 by reinouts, last changed 2008-06-08.04:36:52 by pjenvey.

Messages
msg801 (view) Author: Reinout van Schouwen (reinouts) Date: 2002-12-15.17:33:03
In a project I am working on I want to get a list of
items that are in the __dict__ dictionary of an inner
class. This produces the NPE shown below. If needed I
can provide the code. This happens on both Solaris and
Linux JVMs.

Jython 2.1 on java1.4.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> 
>>> mc = MessageCatalog()
>>> mc.ch.__dict__
{'Language-Team': 'Dutch <vertaling@nl.linux.org>',
'MIME-Version': '1.0', 'POT-Creation-Date':
('2002-12-15 17:27', 1), 'PO-Revision-Date':
('2002-12-15 17:27', 1), 'Content-Transfer-Encoding':
'8bit', 'Project-Id-Version': '', 'Content-Type':
'text/plain; charset=utf-8', '# ': '',
'Last-Translator': ''}
>>> list(mc.ch.__dict__)
Traceback (innermost last):
  File "<console>", line 1, in ?
java.lang.NullPointerException
	at org.python.core.PyList.toString(PyList.java)
	at org.python.core.PyObject.__repr__(PyObject.java)
	at
org.python.core.PySystemState.displayhook(PySystemState.java)
	at
org.python.core.PySystemStateFunctions.__call__(PySystemState.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at org.python.core.Py.printResult(Py.java)
	at org.python.pycode._pyx40.f$0(<console>:1)
	at org.python.pycode._pyx40.call_function(<console>)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyCode.call(PyCode.java)
	at org.python.core.Py.runCode(Py.java)
	at org.python.core.Py.exec(Py.java)
	at
org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
	at
org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java)
	at
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java)
	at
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java)
	at jython.JeditConsole.pushLine(JeditConsole.java:58)
	at jython.LineCommand.doExecute(JeditConsole.java:191)
	at jython.AbstractCommand.execute(JeditConsole.java:141)
	at jython.JythonExecutor.run(JythonExecutor.java:298)
	at java.lang.Thread.run(Thread.java:536)

java.lang.NullPointerException:
java.lang.NullPointerException


msg802 (view) Author: Deleted User leouserz (leouserz) Date: 2006-12-21.15:11:42
Running this source:
class z:
    class t:
        def moo(self): pass

print list(z.t.__dict__)
a = z()
print list(a.t.__dict__)

reproduces the stack in 2.1.  Importing it with the prints removed and creating a z and accessing t.__dict__ via
a = z()
list(a.z.__dict__)
recreates the stack.

But, in Jython3005 this does not occur so it appears to not be reproducible.

leouser
msg803 (view) Author: Khalid Zuberi (kzuberi) Date: 2006-12-21.18:13:14

Great, thanks for checking. Not knowing exactly when/how this was fixed, how about we just make a little bugtest out of your sample code (which should pass currently but would fail in 2.1), and then we can mark this closed.  

- kz
msg3250 (view) Author: Philip Jenvey (pjenvey) Date: 2008-06-08.04:36:48
I added a test for this in r4567, closing out
History
Date User Action Args
2008-06-08 04:36:53pjenveysetstatus: open -> closed
resolution: works for me -> fixed
messages: + msg3250
nosy: + pjenvey
2002-12-15 17:33:03reinoutscreate