Ticket #289 (closed defect: fixed)

Opened 4 months ago

Last modified 3 months ago

Python exception gets mangled when raised inside an ExpandDecider

Reported by: enrico Owned by: richard
Priority: normal Milestone: 1.0.8
Component: Xapian-bindings Version: 1.0.5
Severity: normal Keywords:
Cc: olly Blocked By:
Operating System: Linux Blocking:

Description

When running the attached code, instead of seeing an exception about being unable to decode some \xsomething character, I get this:

$ ./testxapian Traceback (most recent call last):

File "./testxapian", line 29, in <module>

for res in enquire.get_eset(30, rset, Filter()):

TypeError?: function takes exactly 5 arguments (1 given)

I'm using Xapian as in debian lenny: python-xapian 1.0.5-1 and libxapian15 1.0.5-1.

Attachments

testxapian (0.7 kB) - added by enrico 4 months ago.
The self-contained test suite
director_except_test.patch (2.8 kB) - added by richard 3 months ago.
Patch to testsuite to test director exception handling

Change History

Changed 4 months ago by enrico

The self-contained test suite

Changed 4 months ago by olly

  • cc olly added
  • owner changed from olly to richard

Reassigning to Richard, as this is more his area of expertise.

Changed 4 months ago by richard

I've been taking a look at this - I believe the problem is caused by Swig attempting to modify the exception message to add "Swig director method error." to the end of it. I'm not entirely sure why Swig is doing this, but the attempt fails in this case because the constructor of the exception type (UnicodeDecodeError?) is called with a single argument, but requires 5. Hence, the error which you're seeing.

I'll continue to investigate.

Changed 4 months ago by richard

  • status changed from new to assigned

Changed 3 months ago by richard

I've put together a patch to SWIG to fix this. Once this patch is applied to SWIG, we'll have to update to the latest swig version, but after doing that the exception handling should work as expected.

The SWIG patch is at http://sourceforge.net/tracker/index.php?func=detail&aid=2089149&group_id=1645&atid=301645

Changed 3 months ago by richard

Patch to testsuite to test director exception handling

Changed 3 months ago by richard

Attached a patch to pythontest to cover this issue (fails for me with current SWIG, passes with a SWIG with the patch applied).

Changed 3 months ago by richard

  • milestone set to 1.0.9

Marking this for 1.0.9, mainly so we don't forget about it.

Changed 3 months ago by richard

  • milestone changed from 1.0.9 to 1.0.8

Actually, we can fix this by using our own exception type, to bypass the usual SWIG handling. Fixed in this manner on trunk, in revision [11159]. Since we can, this should be fixed in 1.0.8 now - setting the Milestone accordingly.

Changed 3 months ago by olly

  • status changed from assigned to closed
  • resolution set to fixed

Backported to 1.0 [11172]

Note: See TracTickets for help on using tickets.