From on May 26, 2017 13:2
Hello, this is not a bug per se, but rather something I just noticed. I'm including a minimal example console app that will throw with the unexpected message Expected Char, got str, further discussion below the code.
By the way, this is IronPython v2.7.7 on .NET 4.
csharp
class Program
{
static void Main(string[] args)
{
var engine = IronPython.Hosting.Python.CreateEngine();
var foo = new Foo();
var locals = new Dictionary<string object> {{"foo", foo}};
var scope = engine.CreateScope(locals);
var result = engine.Execute("foo.Bar('code', 'a', 7.2)",scope);
Console.ReadLine();
}
}
public class Foo
{
public string Bar(string x, char y, float z = 0)
{
return string.Format("{0}, {1}, {2}", x, y, z);
}
}
</string>
Now, the signature of method Bar of class Foo is of course wrong, in that the last parameter should be double rather than float (or we would need to pass in a System.Single to begin with).
The exception message is a bit misleading, though: Expected Char, got str is not really the hint I would expect. I scratched my head for a minute before realizing I had made a dumb mistake. It seems like it should say something along the lines of Expected Single, got Double.
Just thought I would let you guys know.
Copied from original issue: IronLanguages/main#1660
该提问来源于开源项目:IronLanguages/ironpython2