On Wed Aug 16 05:18:16 2000, gaas wrote: > I have this application (actually Python) that embeds perl and calls > perl_eval_pv() to pass code to it. One problem with this is that > perl_eval_pv(code, FALSE) does not set ERRSV (aka $@) on syntax > errors. > > This is a little example program showing this behaviour: > > --------------------------------------------------------- > #include <EXTERN.h> > #include <perl.h> > > int main(int argc, char**argv, char**env) > { > int i; > char *embedding[] = {"", "-e", "0"}; > PerlInterpreter *my_perl = perl_alloc(); > perl_construct(my_perl); > perl_parse(my_perl, NULL, 3, embedding, NULL); > perl_run(my_perl); > > perl_eval_pv("sub { ", TRUE); > /*** the program ought to abort here ***/ > > if (SvTRUE(ERRSV)) > PerlIO_printf(Perl_debug_log, "XXX %s", SvPV_nolen(ERRSV)); > perl_eval_pv("1/0", TRUE); > if (SvTRUE(ERRSV)) > PerlIO_printf(Perl_debug_log, "YYY %s", SvPV_nolen(ERRSV)); > /*** it aborts here ***/ > > printf("done\n"); > } > > /* > Compile with: cc check-eval-syntax-error.c `perl -MExtUtils::Embed > -e ccopts -e ldopts` > */ > --------------------------------------------------------- > > This program prints: > > $ ./a.out > Illegal division by zero at (eval 2) line 2. > > instead of something with "syntax error in (eval 1)". My embed-fu is weak, but it appears to be a simple fix. http://m-l.org/~perl/misc/0001-Fix-for-perl-3719-Preserve-for-perl_eval_pv-while-em.patch http://github.com/greerga/perl/commit/8ba06c38ccf1582a01143760851f9396c16b78f5 or attached. -- George GreerThread Previous | Thread Next