create or replace function python_traceback() returns void as $$
def first():
  second()

def second():
  third()

def third():
  plpy.execute("select sql_error()")

first()
$$ language plpythonu;

create or replace function sql_error() returns void as $$
begin
  select 1/0;
end
$$ language plpgsql;

create or replace function python_from_sql_error() returns void as $$
begin
  select python_traceback();
end
$$ language plpgsql;

create or replace function sql_from_python_error() returns void as $$
plpy.execute("select sql_error()")
$$ language plpythonu;
