Ok I've been working on the problem quoted at the end of this email and have come up with a solution. but i'm not sure what to make of it.

Poll extends from Model and does not implement __str__ or __unicode__, but inherits __str__ from Model, which calls __unicode__, and __unicode__ from object. however, object.__unicode__ calls __str__, which in this case is model.__str__ and so the loop begins.

of course this code works fine in CPython. so what's different?
simple:

tristan@quiver:~$ python
Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> hasattr(object, '__unicode__')
False
>>>
tristan@quiver:~$ jython
Jython 2.3a0 on java1.5.0_11
Type "copyright", "credits" or "license" for more information.
>>> hasattr(object, '__unicode__')
True
>>>

so, applying the following patch to jython fixes the aforementioned problem. and running 'ant bugtests' shows no change
Index: jython/src/org/python/core/PyObject.java
===================================================================
--- jython/src/org/python/core/PyObject.java    (revision 3484)
+++ jython/src/org/python/core/PyObject.java    (working copy)
@@ -224,7 +224,7 @@
             }
         }
-        dict.__setitem__("__unicode__",new PyMethodDescr("__unicode__",PyObject.class,0,0,new exposed___unicode__(null,null)));
+        //dict.__setitem__("__unicode__",new PyMethodDescr("__unicode__", PyObject.class,0,0,new exposed___unicode__(null,null)));
         class exposed___init__ extends PyBuiltinMethod {
             exposed___init__(PyObject self,PyBuiltinFunction.Info info) {

My question is. Why, if in CPython object.__unicode__ doesn't exist, why does it in jython?


On 20/09/2007, at 7:30 PM, Tristan King wrote:

I've been working on getting the django tutorial to work, and got up to:
---------------
# objects.all() displays all the polls in the database.
Poll.objects.all()
[<Poll: Poll object>]
--------------
before writing this (i'm about to pack it in for the day), which threw me a nasty error:
  ..........
  File "/usr/local/share/jython/Lib/django/db/models/base.py", line 101, in __str__
  File "/usr/local/share/jython/Lib/django/utils/encoding.py", line 37, in force_unicode
  File "/usr/local/share/jython/Lib/django/db/models/base.py", line 101, in __str__
  File "/usr/local/share/jython/Lib/django/utils/encoding.py", line 37, in force_unicode
java.lang.StackOverflowError: java.lang.StackOverflowError