Message1830
Patch is added with the patch number: [1773865]
Problem:
========
PyString.java
-------------
final static PyObject str_new(PyNewWrapper new_, boolean init, PyType subtype,
PyObject[] args, String[] keywords) {
ArgParser ap = new ArgParser("str", args, keywords, new String[] { "object" }, 0);
PyObject S = ap.getPyObject(0, null);
if(new_.for_type == subtype) {
if(S == null) {
return new PyString("");
}
return S.__str__();
---
---
---
}
Here S is an arg of type PyStringDerived. When you call S.__str__(),
it is returning a string of type PyStringDerived with the contents of arg.
But this leads to making calls to __init__ of mystr class as in the
following.
PyType.java
------------
private static PyObject invoke_new_(PyObject new_,PyType type .....{
...
newobj.dispatch__init__(type,args,keywords);
return newobj;
}
Here newobj is nothing but an obj of type PyStringDerived. This causes
the invocation of the following code.
PyStringDerived.java
---------------------
public void dispatch__init__(PyType type,PyObject[]args,String[]keywords) {
PyType self_type=getType();
if (self_type.isSubType(type)) {
PyObject impl=self_type.lookup("__init__");
<<< call to __init__ of mystr >>>
}}
So here, the constructor is called recursively and it causes stackoverflow.
Solution:
=========
PyString.java
-------------
final static PyObject str_new(PyNewWrapper new_, boolean init, PyType subtype,
PyObject[] args, String[] keywords) {
---
return new PyString(S.__str__().toString()); //CHANGE
---
}
|
|
Date |
User |
Action |
Args |
2008-02-20 17:17:58 | admin | link | issue1768990 messages |
2008-02-20 17:17:58 | admin | create | |
|