Issue1800378

classification
Title: object.__unicode__ should it exist?
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, tristanlk
Priority: normal Keywords:

Created on 2007-09-22.22:35:57 by tristanlk, last changed 2007-09-25.16:36:55 by cgroves.

Files
File name Uploaded Description Edit Remove
test_unicode.py tristanlk, 2007-09-23.23:08:23
test_unicode.py tristanlk, 2007-09-25.07:58:01
Messages
msg1924 (view) Author: tristan (tristanlk) Date: 2007-09-22.22:35:57
I've been having a few problems moving python code (specifically django) to jython, which is caused by the fact that object.__unicode__ exitst. It doesn't in CPython, so why does it exist in jython?
msg1925 (view) Author: tristan (tristanlk) Date: 2007-09-23.23:08:24
i've attached a file which shows this problem.
File Added: test_unicode.py
msg1926 (view) Author: Charlie Groves (cgroves) Date: 2007-09-25.04:29:58
__unicode__ descriptor removed on trunk in r3538.
msg1927 (view) Author: tristan (tristanlk) Date: 2007-09-25.07:58:01
the descriptor is not the only problem here.
attached an updated test_unicode.py which shows the need for the changes to the PyObject.__unicode__ function.
File Added: test_unicode.py
msg1928 (view) Author: Charlie Groves (cgroves) Date: 2007-09-25.16:36:55
Ahh, I was assuming code similar to what you added to PyObject was already in PyInstance.  If it wasn't there, unicode(obj) wouldn't call obj.__unicode__ if obj was a classic class.  Guess I shouldn't have assumed that worked.  I fixed that in r3542 and your test case works.  All instances of Python classes are actually instances of PyInstance in the Jython runtime,  so by adding that __unicode__ lookup there, it correctly calls the method.

This may actually explain why someone added the descriptor in the first place.  They didn't understand the PyInstance to Python object instance mapping and were trying to get __unicode__ visible on Python classes.  I'm grasping at straws here though.

Thanks for tracking this down!
History
Date User Action Args
2007-09-22 22:35:57tristanlkcreate