Opened 16 years ago
Closed 16 years ago
#289 closed defect (fixed)
Python exception gets mangled when raised inside an ExpandDecider
Reported by: | Enrico Zini | Owned by: | Richard Boulton |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.8 |
Component: | Xapian-bindings | Version: | 1.0.5 |
Severity: | normal | Keywords: | |
Cc: | Olly Betts | Blocked By: | |
Blocking: | Operating System: | Linux |
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 (2)
Change History (10)
by , 16 years ago
Attachment: | testxapian added |
---|
comment:1 by , 16 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Reassigning to Richard, as this is more his area of expertise.
comment:2 by , 16 years ago
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.
comment:3 by , 16 years ago
Status: | new → assigned |
---|
comment:4 by , 16 years ago
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
by , 16 years ago
Attachment: | director_except_test.patch added |
---|
Patch to testsuite to test director exception handling
comment:5 by , 16 years ago
Attached a patch to pythontest to cover this issue (fails for me with current SWIG, passes with a SWIG with the patch applied).
comment:6 by , 16 years ago
Milestone: | → 1.0.9 |
---|
Marking this for 1.0.9, mainly so we don't forget about it.
comment:7 by , 16 years ago
Milestone: | 1.0.9 → 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.
The self-contained test suite