plpython: sys module doesn't know about _getframe - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject plpython: sys module doesn't know about _getframe
Date
Msg-id 200106032032.f53KWFL40251@hub.org
Whole thread Raw
List pgsql-bugs
Steven D. Arnold (stevena@neosynapse.net) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
plpython: sys module doesn't know about _getframe

Long Description
I have a module which I import and use in plpython functions.  One function in this module imports sys and then uses
sys._getframe(). When it tries to do this, plpython says: 

exceptions.AttributeError: 'sys' module has no attribute '_getframe'

The same function using Python directly works fine.  Does plpython use a specialized version of Python or a specialized
sysmodule? 

Sample Code
create function foo() returns integer as '
    import data_handler
    result = data_handler.qse("""SELECT * FROM users""")
    return 1
' language 'plpython';

[In module data_handler]
import sys
def qse(s, layers=1):
    loc = sys._getframe(layers).f_locals
    glb = sys._getframe(layers).f_globals
    [...]
    return s


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Trigger causes the server to crash with SEGV
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: repeated syntax errors in plpython modules cause database to reset