<div class="gmail_quote">On Mon, Apr 14, 2008 at 6:02 AM, Trent Nelson &lt;<a href="mailto:tnelson@onresolve.com">tnelson@onresolve.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
On Windows x64, sizeof(size_t) &gt; sizeof(long), so the existing PyLong_FromSsize_t and PyLong_FromSize_t implementations in longobject.c are just plain wrong. &nbsp;I&#39;ve patched it as follows, but as I&#39;m not well versed in the many intricacies of longobject.c, I&#39;d appreciate input from others.<br>
</blockquote><div><br></div><div>I&#39;m missing something: &nbsp;in what way are the existing implementations</div><div>wrong? &nbsp;I see that the test &nbsp;(ival &lt; PyLong_BASE) in&nbsp;</div><div>PyLong_FromSsize_t&nbsp;should be something like:</div>
<div>(ival &lt; PyLong_BASE &amp;&amp; ival &gt; -PyLong_BASE), but</div><div>PyLong_FromSize_t looks okay to me. &nbsp;(Apart from the</div><div>unused &quot;int one = 1;&quot;, that is.)</div><div><br></div><div>I agree that it&#39;s a little odd to go via _PyLong_FromByteArray.<br>
</div><div><br></div><div>Couldn&#39;t PyLong_FromSsize_t be written to exactly mimic</div><div>PyLong_FromLongLong? &nbsp;It means duplication of code, I know,</div><div>but it also means not relying on ssize_t being equal to either</div>
<div>long or long long.</div><div><br></div><div>By the way, I don&#39;t much like the handling of negative</div><div>values in PyLong_FromLong and PyLong_FromLongLong:</div><div>these functions use code like:</div><div><br>
</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (ival &lt; 0) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ival = -ival;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>negative = 1;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div></div><div>which looks to me as though it might mishandle the case</div><div>where ival = LONG_MIN. &nbsp;Should this be fixed?</div><div>
<br></div><div>Mark</div></div>