Embedding: How to set globals for PyObject_Call

Michael Hudson mwh at python.net
Thu Feb 21 11:59:53 EST 2002


xscottgjunk at yahoo.com (Scott Gilbert) writes:

>   // This one breaks
>   Var g = VarEval("globals");
>   g(); // This causes a segfault

Do we get to see the backtrace?

>   // This one works
>   Var g = VarEval("globals()");
> 
>   // As you pointed out, This one works too
>   VarExec("def GLOBALS(): return globals()");
>   Var g = VarEval("GLOBALS");
>   g();
> 
> Many other functions in the __builtin__ module work just fine.  For
> instance:
> 
>   Var hex = VarEval("hex");
>   VarPrint(hex(1234));
> 
> So I think it's a little odd that some builtins are different in this
> regard than others.

I'd agree here.

Cheers,
M.

-- 
  Guido (like us!) is a bit schizophrenic here: he wants to be a
  benevolent dictator, but also wants to treat people like
  grownups. This probably worked better before Python got a large
  American audience <0.9 wink>.             -- Tim Peters, 10 Feb 2000



More information about the Python-list mailing list