# HG changeset patch # User Colin Macdonald # Date 1470935726 25200 # Node ID 140e37e8e95a394220fb2a3af60f57128ab5b981 # Parent d4744d829ee06ff917d23c32a5620f0ad6760d5d Don't create pyobjects within the pyobject ctor It seems to work, but maybe there are subtle bugs. * @pyobject/pyobject.m: Use an insert function. diff -r d4744d829ee0 -r 140e37e8e95a @pyobject/pyobject.m --- a/@pyobject/pyobject.m Wed Aug 10 15:41:05 2016 -0700 +++ b/@pyobject/pyobject.m Thu Aug 11 10:15:26 2016 -0700 @@ -50,14 +50,14 @@ " __import__('__main__')._InOctave = dict()" ]; pyexec (cmd); - ## XXX: perhaps not the ideal implementation! - vars = pyeval ("__import__('__main__').__dict__"); - ## this is vars{"_temp"} = x - idx = struct ("type", "{}", "subs", {{"_temp"}}); - vars = subsasgn (vars, idx, x); + ## Function to insert and return the hex id + cmd = [ "def _in_octave_insert(x):\n" ... + " h = hex(id(x))\n" ... + " __import__('__main__')._InOctave[h] = x\n" ... + " return h" ]; + pyexec (cmd); - pyexec ("__import__('__main__')._InOctave[hex(id(_temp))] = _temp") - id = pyeval (["hex(id(_temp))"]); + id = pycall ("_in_octave_insert", x); obj = pyobject (0, id); endif return