[IronPython] Bug in beta9?

Martin Maly Martin.Maly at microsoft.com
Thu Jul 13 21:41:45 PDT 2006


Dino is absolutely right. In our new conversion rules, there is no implicit conversion between integer types (both standard Python types - int and bigint, and CLR integer types - byte, sbyte, short, ushort, long, ulong, uint, decimal) and char. Char is in Python pretty much interchangeable with one-character string and we tried to find the right balance for conversions that are implicit and those which require explicit 'cast'. Consider for example CPython's:

>>> range('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: range() integer end argument expected, got str.

You can still do int("1") or int(Char.Parse('a')), both explicit conversions.

Hope this helps.

Martin


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Thursday, July 13, 2006 4:47 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Bug in beta9?

I think this is probably due to some changes w/ method dispatch (we'll no longer convert from char to int?).  I'll have to ask around to see if that's part of the design or not.  As a work around you can do:

chr(ord(a.KeyChar))


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jörgen Stenarson
Sent: Thursday, July 13, 2006 3:17 PM
To: Discussion of IronPython
Subject: [IronPython] Bug in beta9?

Hi

I have hit a change in the behaviour that results in an exception. Is this behaviour expected? My workaround for now is to change chr to str.

/Jörgen

file(tipy.py) used in test:

import System
readkey=System.Console.ReadKey
print "Press a key"
a=readkey(True)
print chr(a.KeyChar)

Test with beta8:
 >c:\IronPython-1.0-Beta8\IronPythonConsole.exe tipy.py Press a key d


Test with beta9:
 >c:\IronPython-1.0-Beta9\ipy -i tipy.py Press a key Traceback (most recent call last):
   File C:\python\pyreadline_branch\pyreadline\console\tipy.py, line 8, in Initialize
   File , line 0, in Chr##75
TypeError: Cannot convert Char(d) to Int32

_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list