[IronPython] Difference in 1.1 and 2.0 with Dialog Result
dinov at exchange.microsoft.com
Wed Jan 2 19:04:00 CET 2008
I think this is bug - .NET conventions say that enum's should generally have a zero value (FxCop CA1008 :)). Because of that we can safely define __nonzero__ on enums and have that return true/false based upon if the value is zero/non-zero. Otherwise Python says all expressions otherwise defined return true, which is the default behavior you're getting here.
This regression probably occurred when I was switching conversions over to using dynamic sites and actions. The if (expr) is implemented as a conversion to bool and that of course is now returning true (just as bool(someEnum) always returns true now).
Interestingly enough neither v1.x or v2.0 have ever defined __nonzero__ on bool's - it's just that our "fast paths" (which have been slowly going away in v2.0) have caught this and done the right thing. I've opened CodePlex bug #14605 to track the issue (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=14605). Thanks for the bug report!
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Davy Mitchell
Sent: Sunday, December 23, 2007 6:21 AM
To: Discussion of IronPython
Subject: [IronPython] Difference in 1.1 and 2.0 with Dialog Result
from System.Windows.Forms import DialogResult
The above prints Boo! in 1.1 and early 2.0 Alphas i.e. DialogResult.OK
resolves to TRUE.
A6 and A7 (didn't try any others!) nothing is printed i.e.
DialogResult.OK resolves to FALSE.
Now, I am changing my dialog code anyway but is this a deliberate change?
Blog - http://www.latedecember.co.uk/sites/personal/davy/
Twitter - http://twitter.com/daftspaniel
Skype - daftspaniel needgod.com
Users mailing list
Users at lists.ironpython.com
More information about the Ironpython-users