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! -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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 import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import DialogResult if DialogResult.OK: print "Boo!" 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? Cheers, Davy -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel needgod.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
