Issue1382

classification
Title: __cmp__ on certain types raises ArrayStoreException
Type: crash Severity: normal
Components: Core Versions: 2.5.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: pjenvey, rhudson@annapmicro.com, ssteiner
Priority: Keywords:

Created on 2009-06-18.20:46:10 by rhudson@annapmicro.com, last changed 2009-09-09.03:48:31 by pjenvey.

Messages
msg4822 (view) Author: (rhudson@annapmicro.com) Date: 2009-06-18.20:46:09
I get an ArrayStoreException while doing a __cmp__ operation. It occurs
in PyType.java at 1073:

                    where[0] = t;

While the 'where' parameter is declared as a PyObject[], over in
PyObjectDerived at line 770 it is created as an array of PyType[] and
passed to lookup_where on the following line.

        PyType[]where_type=new PyType[1];
        PyObject impl=self_type.lookup_where("__cmp__",where_type);

The exception indicates that the actual type being assigned is PyClass.
PyClass is a PyObject, but not a PyType which appears to be the cause of
the exception.
msg4823 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-19.01:05:25
Please provide a short test or at least a snippet of code that reproduces 
the problem. A formal test for this probably belongs in test.test_cmp_jy
msg4825 (view) Author: (rhudson@annapmicro.com) Date: 2009-06-19.18:10:19
I tried to produce a simple example that recreates the problem. That, of
course, didn't work.

I assume the issue is that lookup_where is not allowed to return an
object of type PyClass?

If lookup_where is allowed to return any type other than a PyType or one
of its descendants (and it's typed as PyObject so it could easily do
so), then I believe that the code is incorrect by inspection. The array
definition should be PyObject instead of PyType.

If, however, by convention lookup_where is only allowed to return
descendants of PyType (even though the type is PyObject) then the bug
lies elsewhere in something that's causing it to violate the convention.

If I can produce a simple example, I'll send it in.
msg4845 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-21.23:10:09
I agree there's a bug from what you described, but it needs a test to be 
fixed
msg5073 (view) Author: simon steiner (ssteiner) Date: 2009-08-27.10:00:37
I get error for:

import UserDict
class Configuration(object, UserDict.DictMixin):
    def __init__(self):
        pass
x = Configuration()
print x != None
msg5121 (view) Author: Philip Jenvey (pjenvey) Date: 2009-09-09.03:48:31
thanks for the example Simon, fixed in r6769/r6770
History
Date User Action Args
2009-09-09 03:48:31pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5121
2009-09-09 03:39:08pjenveysettitle: ArrayStoreException -> __cmp__ on certain types raises ArrayStoreException
2009-09-09 03:27:46pjenveysetassignee: pjenvey
2009-08-27 10:00:38ssteinersetnosy: + ssteiner
messages: + msg5073
versions: + 2.5.0, - 25rc4
2009-06-21 23:10:09pjenveysetmessages: + msg4845
2009-06-19 18:10:19rhudson@annapmicro.comsetmessages: + msg4825
2009-06-19 01:05:26pjenveysetnosy: + pjenvey
messages: + msg4823
2009-06-18 20:46:10rhudson@annapmicro.comcreate