Edgewall Software

Opened 11 years ago

Closed 11 years ago

#574 closed defect (fixed)

SystemError: error return without exception set

Reported by: rblank Owned by: hodgestar
Priority: major Milestone:
Component: General Version: devel
Keywords: Cc:

Description

When _speedups is enabled:

>>> from genshi.core import Markup
>>> Markup(',').join(iter('abc'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: error return without exception set

Markup.join() is documented as taking a sequence, so this is an invalid call. But it should raise a TypeError instead. Interestingly, this makes the method slightly incompatible with the pure-Python one, which accepts iterators.

The fix is something like:

  • genshi/_speedups.c

     
    251251        return NULL;
    252252    }
    253253    if (!PySequence_Check(seq)) {
     254        PyErr_SetString(PyExc_TypeError, "join() requires a sequence");
    254255        return NULL;
    255256    }
    256257    n = PySequence_Size(seq);

Attachments (1)

574-markup-join-iter.patch (1.5 KB) - added by rblank 11 years ago.
Accept iterators for Markup.join().

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by rblank

Accept iterators for Markup.join().

comment:1 Changed 11 years ago by rblank

  • Owner changed from cmlenz to hodgestar

Alternatively, Markup.join() could be made to accept iterators, in the same way as its pure Python implementation does. 574-markup-join-iter.patch implements this.

comment:2 Changed 11 years ago by hodgestar

  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the patch rblank!

Test and patch committed in r1266. Backported to 0.7.x (r1267) and 0.6.x (r1268).

Note: See TracTickets for help on using tickets.