You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Barry Pederson <bp...@barryp.org> on 2003/06/08 19:16:50 UTC

tableobject - SystemError: error return without exception set

I was trying to use mod_python 3.0.3 with SimpleTAL (3.2), and found 
that when trying to access req.headers_in through a TALES expression, 
mod_python would fail with:

    SystemError: error return without exception set

and afterwards become unusable, requiring an apache restart.

Turns out SimpleTAL is using unicode, and the check in 
tableobject.c::table_has_key() is not setting an exception like it should.

An easy non-SimpleTAL way to see the problem is to use the mod_python 
publisher with something like:

    def index(req):
         return req.headers_in.has_key(u'foo')

I've attached a small patch to fix this one particular problem - but 
browsing through tableobject.c it looks like there are quite a few 
places where NULL is returned without an exception being set that may be 
trouble.

Also, SimpleTAL still doesn't work for accessing req.headers_in because 
of the unicode, but at least the error will be

    TypeError: table keys must be strings

and leaves mod_python less freaked-out.  I'll be willing to work on more 
cleanups if necessary - but I thought I'd bring this up first and see if 
anyone's paying attention to this list.

     Barry

(BTW...is there an archive for this mailing list?  an bug database?)

Re: tableobject - SystemError: error return without exception set

Posted by Barry Pederson <bp...@barryp.org>.
Gregory (Grisha) Trubetskoy wrote:

> Thanks for the patch, if you find more, please send them in, they are much
> appreciated! Off the top of my head - if the NULL is a result of a Python
> API call, then the error is already set, no need to worry about it, but in
> all other cases it should be set.

You're right of course...on second look the rest of those NULL returns seem 
OK.

In looking it over again though , I ran across something in 
table_subscript() that may be a memory leak.  A list is created, but if 
there's no match ("no mach"), the reference to the list isn't decremented. 
  I've attached another small patch.

	Barry

Re: tableobject - SystemError: error return without exception set

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
On Sun, 8 Jun 2003, Barry Pederson wrote:

> I've attached a small patch to fix this one particular problem - but
> browsing through tableobject.c it looks like there are quite a few
> places where NULL is returned without an exception being set that may be
> trouble.

Thanks for the patch, if you find more, please send them in, they are much
appreciated! Off the top of my head - if the NULL is a result of a Python
API call, then the error is already set, no need to worry about it, but in
all other cases it should be set.

> BTW...is there an archive for this mailing list?

Goog question - I don't think there is a public one, just like with most
@httpd.apache.org lists. :-(

> an bug database?

Nope... Not yet at least...

Grisha