From: Philip J. <pj...@un...> - 2010-04-27 03:47:14
|
On Apr 26, 2010, at 7:27 AM, zy...@us... wrote: > Revision: 7047 > http://jython.svn.sourceforge.net/jython/?rev=7047&view=rev > Author: zyasoft > Date: 2010-04-26 14:27:38 +0000 (Mon, 26 Apr 2010) > > Log Message: > ----------- > Fixed weakref leak in calling functions with kwargs by nulling out after call (in compiler). Fixes #1586. Bumped bytecode magic > > Modified Paths: > -------------- > trunk/jython/Lib/test/test_weakref_jy.py > trunk/jython/src/org/python/compiler/CodeCompiler.java > trunk/jython/src/org/python/core/imp.java > trunk/jython/src/org/python/modules/thread/PyLocal.java > > Modified: trunk/jython/src/org/python/modules/thread/PyLocal.java > =================================================================== > --- trunk/jython/src/org/python/modules/thread/PyLocal.java 2010-04-25 18:33:34 UTC (rev 7046) > +++ trunk/jython/src/org/python/modules/thread/PyLocal.java 2010-04-26 14:27:38 UTC (rev 7047) > @@ -59,7 +59,9 @@ > if (where[0] == TYPE && args.length > 0) { > throw Py.TypeError("Initialization arguments are not supported"); > } > - this.args = args; > + // caller zeros out `args` > + this.args = new PyObject[args.length]; > + System.arraycopy(args, 0, this.args, 0, args.length); > this.keywords = keywords; > } This this can affect any class that saves args for later, like _functools.partial (and I think there's others), right? Can we have the compiler just null its reference to the array instead of zero'ing it, and avoid the need for copying? -- Philip Jenvey |