[IronPython] Id: 356 unicode throws when creating a Unicode string from an invalid Unicode string (was Re: Importing embedded .py files)

JoeSox joesox at gmail.com
Thu Jul 6 09:01:08 CEST 2006


On 7/5/06, Dino Viehland <dinov at exchange.microsoft.com> wrote:
> Ahh, excellent!   I hadn't seen this mail yet when I wrote my other one, and this is exactly what I wanted to see (the call to str).
>

Yes, I hoped so.
the line before the call to str was....

221:        if isinstance(s, unicode):
222:            s = str(s)

It looks like I will have to download the VS 2005 June 2006 CTP to see
if I can step thru this code any better because I am having trouble
understanding what is the exact string value of s at the time of
execution.  But this confusion may also be caused by my recent pain
medication for a kidney stone that is getting surgically removed in
the morning.

> The only fix I can see for this at this time is supporting 2 different constructors for str & unicode, one which will throw if the conversion fails, and one which won't.
>

Out of curiousity, would those future conversion evaluations be using
IronPython.Runtime.Converter?

I was looking at that to see how that worked and I tried the below
code and I don't think it converted it correctly (conv=None) but I
could be doing something wrong.

Conversion conv = new Conversion();
string replacement = Converter.TryConvertToString(655, out conv);
string replacement2 =
Converter.TryConvertToString(Convert.ToUInt64("3"), out conv);

-- 
Later, Joe



More information about the Ironpython-users mailing list