[Python-Dev] Python 1.5.2 modules need porting to 2.0 because of unicode - comments please

Guido van Rossum guido@beopen.com
Mon, 18 Sep 2000 18:45:12 -0500


> I have managed to get all our critical python code up and
> running under 2.0b1#4, around 15,000 lines. We use win32com
> and wxPython extensions. The code drive SourceSafe and includes
> a Web server that schedules builds for us.
> 
> The only problem I encounted was the problem of mixing string
> and unicode types.
> 
> Using the smtplib I was passing in a unicode type as the body
> of the message. The send() call hangs. I use encode() and all
> is well.
> 
> Is this a user error in the use of smtplib or a bug?
> 
> I found that I had a lot of unicode floating around from win32com
> that I was passing into wxPython. It checks for string and raises
> exceptions. More use of encode() and we are up and running.
> 
> Is this what you expected when you added unicode?

Barry, I'm unclear on what exactly is happening.  Where does the
Unicode come from?  You implied that your code worked under 1.5.2,
which doesn't support Unicode.  How can code that works under 1.5.2
suddenly start producing Unicode strings?  Unless you're now applying
the existing code to new (Unicode) input data -- in which case, yes,
we expect that fixes are sometimes needed.

The smtplib problem may be easily explained -- AFAIK, the SMTP
protocol doesn't support Unicode, and the module isn't Unicode-aware,
so it is probably writing garbage to the socket.

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)