<div class="gmail_quote">On Mon, Apr 14, 2008 at 6:02 AM, Trent Nelson <<a href="mailto:tnelson@onresolve.com">tnelson@onresolve.com</a>> 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) > sizeof(long), so the existing PyLong_FromSsize_t and PyLong_FromSize_t implementations in longobject.c are just plain wrong. I've patched it as follows, but as I'm not well versed in the many intricacies of longobject.c, I'd appreciate input from others.<br>
</blockquote><div><br></div><div>I'm missing something: in what way are the existing implementations</div><div>wrong? I see that the test (ival < PyLong_BASE) in </div><div>PyLong_FromSsize_t should be something like:</div>
<div>(ival < PyLong_BASE && ival > -PyLong_BASE), but</div><div>PyLong_FromSize_t looks okay to me. (Apart from the</div><div>unused "int one = 1;", that is.)</div><div><br></div><div>I agree that it's a little odd to go via _PyLong_FromByteArray.<br>
</div><div><br></div><div>Couldn't PyLong_FromSsize_t be written to exactly mimic</div><div>PyLong_FromLongLong? 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'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 < 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. Should this be fixed?</div><div>
<br></div><div>Mark</div></div>