Issue462280

classification
Title: builtin method as a class variable
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn
Priority: normal Keywords:

Created on 2001-09-17.17:01:28 by anonymous, last changed 2001-10-30.19:01:31 by bckfnn.

Messages
msg412 (view) Author: Nobody/Anonymous (nobody) Date: 2001-09-17.17:01:28
This has a simple test case, but I'm not sure that the 
solution is simple. This particular case is in the 
context of a list object, but it is possible that 
other objects suffer from the same problem.

Jython 2.1a3 on java1.3.0 (JIT: null)
Type "copyright", "credits" or "license" for more 
information.
>>> class Foo:
...   mylistIndex = ['a', 'b', 'c', 'd', 'e'].index
...
>>> a = Foo()
>>> a.mylistIndex
<builtin method 'index'>
>>> a.mylistIndex('c')
Traceback (innermost last):
  File "<console>", line 1, in ?
TypeError: index(): expected 1 args; got 2
>>>
>>> Foo.mylistIndex('c')
Traceback (innermost last):
  File "<console>", line 1, in ?
java.lang.NullPointerException
        at org.python.core.ListFunctions.__call__
(PyList.java)
        at org.python.core.PyObject.invoke
(PyObject.java)
        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)
        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
(InteractiveInterpret
er.java)
        at
org.python.util.InteractiveInterpreter.runsource
(InteractiveInterpret
er.java)
        at org.python.util.InteractiveConsole.push
(InteractiveConsole.java)
        at
org.python.util.InteractiveConsole.interact
(InteractiveConsole.java)
        at org.python.util.jython.main(jython.java)

java.lang.NullPointerException: 
java.lang.NullPointerException


For reference, CPython doesn't choke on this:

Python 2.1 (#1, Apr 17 2001, 09:45:01)
[GCC 2.95.3-2 (cygwin special)] on cygwin_nt-4.01
Type "copyright", "credits" or "license" for more 
information.
>>> class Foo:
...   mylistIndex = ['a', 'b', 'c', 'd', 'e'].index
...
>>> a = Foo()
>>> a.mylistIndex
<built-in method index of list object at 0xa04da34>
>>> a.mylistIndex('c')
2
>>>
msg413 (view) Author: Finn Bock (bckfnn) Date: 2001-10-30.19:01:31
Logged In: YES 
user_id=4201

Added as test328.py
History
Date User Action Args
2001-09-17 17:01:28anonymouscreate