[IronPython] Django, __unicode__, and #20366

Vernon Cole vernondcole at gmail.com
Thu Feb 11 21:42:08 CET 2010

Dear Dino and Jeff:
   I think we are all on the same wavelength.  IronPython makes unicode and
str the same implicitly.  Python 3 makes them the same explicitly -- by
getting rid of __unicode__ completely.
   The effort to make django (or any other application) run on IronPython
and the effort to make it run on Python 3 should be compatible.  The same
code changes should be applicable to both platforms, since they both make
the same underlying change in design -- that all strings are unicode.  I
discovered that my efforts to make adodbapi run on IronPython went a long
way toward getting it ready to run on Python 3.  That's why I included a
2to3 pass on my earlier code sample. It clearly shows that IronPython's
implementation of str() overshoots the mark.  A tiny flaw in an amazing
project.  (Did you notice that CPython 2.6 raised an Encode exception while
IPy raised Decode? I almost missed that.)

So, yes, any changes in the str vs. unicode handling of IronPython should be
moves TOWARD Python 3, and should use the same syntax if possible.

Module authors should be able to do something like:

if sys.platform == 'cli' or sys.version_info[0] >= '3':
   def __str__(self):
       #blah blah blah
    def __unicode__(self):
       #blah blah blah
    def __str__(self):
       #different blah blah
P.S.: Speaking of django, I placed an alpha-test version of adodbapi (with
django compatability added) on the mercurial source tree at
<http://sourceforge.net/projects/adodbapi%20>. It is heavily refactored, so
I would be grateful to anyone who is willing to kick it around to see how
well it holds up. All volunteers happily accepted.  It should work on either
IronPython or Python 3.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100211/102b6765/attachment.html>

More information about the Ironpython-users mailing list