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

Dino Viehland dinov at exchange.microsoft.com
Thu Jul 6 08:52:24 PDT 2006


They'd actually use StringOps.Decode (we get there via StringOps.Make)- currently this sees if we have any characters outside of the ASCII range and if so does a decode - and that's what's blowing up.

Another interesting data point is that we could also change the way isinstance works.  All this is a little scary though - I think it'll be hard to get something that works consistently and seems to make sense, but it's worth trying to investigate and see if we can come up with something that works closer to CPython then what we have now (though we'll probably never be perfect here).

________________________________________
From: users-bounces at lists.ironpython.com On Behalf Of JoeSox
Sent: Thursday, July 06, 2006 12:01 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Id: 356 unicode throws when creating a Unicode        string from an invalid Unicode string (was Re: Importing        embedded .py files)

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
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list