<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:Z="urn:schemas-microsoft-com:" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Actually it’s not related to the interfaces –
DataRow implements no interfaces! Instead what it has is a default member
which we of course map into __getitem__. And Python says that all things
with __getitem__ can be enumerated by going from 0 until you get an exception.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>In 2.0 we apparently support this conversion on user defined
types but not on built-in .NET types. I’m actually doing some work
now which will unify the .NET vs User-Defined type code paths so this will go
away but I’ve opened bug #17142 to track this (<a
href="http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=17142">http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=17142</a>).
That way afterwards we’ll make sure we’ve got a test in place and
it won’t regress in the future.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Now that being said you probably don’t actually want to be
doing this for performance reasons </span><span style='font-size:11.0pt;
font-family:Wingdings;color:#1F497D'>J</span><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>. The way we know this
iteration is complete is when an exception is thrown which is going to be bad
for perf. Calling row.ItemArray is going to give you a real enumerable
object which terminates w/o an exception so you may see better perf that way - of
course that seems to make a copy of all the rows, so there’s a trade-off to
be made here…<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Curt Hagenlocher<br>
<b>Sent:</b> Monday, June 23, 2008 8:37 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] DataRows and IronPython 2.0 B3<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<p class=MsoNormal>It's very unlikely that this was intentional. I
suspect that it's related to a change in the way we handle interfaces -- this
wouldn't be the first unanticipated consequence of that change. :/<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><br>
<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>On Mon, Jun 23, 2008 at 8:30 AM, Michael Foord <<a
href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>>
wrote:<o:p></o:p></p>
<p class=MsoNormal>Note that we can fix it by iterating over 'row.ItemArray'
instead, I just wondered if the breakage was intentional.<br>
<span style='color:#888888'><br>
Michael Foord</span> <o:p></o:p></p>
<div>
<div>
<p class=MsoNormal><br>
<br>
Michael Foord wrote:<o:p></o:p></p>
<p class=MsoNormal>Hello all,<br>
<br>
I'm further investigating potential compatibility issues with moving Resolver
One to IronPython 2, and I've encountered a change in behaviour with respect to
iterating over DataRows.<br>
<br>
The script below works in IronPython 1, printing all the data in the rows. In
IronPython 2.0 B3 it raises an exception.<br>
<br>
IronPython 1:<br>
C:\compile>c:\Binaries\ironpython\ipy.exe test_data.py<br>
0 System.Data.DataRow<br>
0 A Big Boy Did It and Ran Away<br>
1 System.Data.DataRow<br>
0 Affective Computing<br>
2 System.Data.DataRow<br>
0 Clear and Present Danger<br>
<br>
IronPython 2:<br>
C:\compile>c:\Binaries\ironpython2\ipy.exe test_data.py<br>
0 <System.Data.DataRow object at 0x000000000000002B
[System.Data.DataRow]><br>
Traceback (most recent call last):<br>
File "test_data.py", line 29, in test_data.py<br>
TypeError: expected IEnumerator, got DataRow<br>
<br>
<br>
Test script:<br>
<br>
import clr<br>
clr.AddReference('System.Data')<br>
<br>
from System.Data import DataSet<br>
from System.Data.Odbc import OdbcConnection, OdbcDataAdapter<br>
<br>
<br>
connectString = (<br>
"DRIVER={MySQL ODBC 3.51 Driver};"<br>
"blah blah blah"<br>
"OPTION=3;"<br>
)<br>
<br>
query = "SELECT title FROM books WHERE price > 2 ORDER BY title"<br>
<br>
connection = OdbcConnection(connectString)<br>
adaptor = OdbcDataAdapter(query, connection)<br>
dataSet = DataSet()<br>
connection.Open()<br>
adaptor.Fill(dataSet)<br>
connection.Close()<br>
<br>
for rowIndex, row in enumerate(dataSet.Tables[0].Rows):<br>
print rowIndex, row<br>
for colIndex, data in enumerate(row):<br>
print ' ', colIndex, data<br>
<br>
Michael Foord<br>
<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>
<p class=MsoNormal><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>
</div>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>