Author arnebef
Recipients arnebef, r_walter
Date 2008-06-03.21:56:43
SpamBayes Score 0.015911771
Marked as misclassified No
Message-id <>
Ok, this should be a better patch (not beautiful, but should work).

The problem is in merge_lo/merge_hi in mergestate. These have been
copied from listobject.c

In listobject.c there are these lines:
static Py_ssize_t merge_lo(... {
  if (na == 0)
    goto Succeed;
    result = 0;
    if (nb)
      memcpy(dest-(nb-1), baseb, nb * sizeof(PyObject*));
    return result;

Because of gotos fall through, when Succeed is jumped, Fail is also

In MergeState it has been convert to these lines:
void merge_lo(...) {
  if (nb == 0)
  try { ... }
  finally {
    if (na != 0)
      System.arraycopy(this.a, pa, this.kvdata, dest, na);

Basically, in the C implementation, Fail will also be performed when
Succeed is performed, while in the Java implementation, the finally tag
will never be entered if nb == 1 when starting. This means that
this.kvdata[pa] = this.kvdata[pb], and the sort is not a sort anymore ;)

Patch attached (sorterror_updated)
Date User Action Args
2008-06-03 21:56:45arnebefsetspambayes_score: 0.0159118 -> 0.015911771
messageid: <>
2008-06-03 21:56:45arnebefsetspambayes_score: 0.0159118 -> 0.0159118
recipients: + arnebef, r_walter
2008-06-03 21:56:44arnebeflinkissue1835099 messages
2008-06-03 21:56:44arnebefcreate