From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Lfk2m-00066e-Gf for garchives@archives.gentoo.org; Sat, 07 Mar 2009 00:05:32 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 00081E03B3; Sat, 7 Mar 2009 00:05:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C3F87E03B3 for ; Sat, 7 Mar 2009 00:05:31 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 69A1164238 for ; Sat, 7 Mar 2009 00:05:31 +0000 (UTC) Received: from zmedico by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1Lfk2l-0000Gy-7C for gentoo-commits@lists.gentoo.org; Sat, 07 Mar 2009 00:05:31 +0000 To: gentoo-commits@lists.gentoo.org From: "Zac Medico (zmedico)" Subject: [gentoo-commits] portage r12772 - main/trunk/pym/portage X-VCS-Repository: portage X-VCS-Revision: 12772 X-VCS-Files: main/trunk/pym/portage/util.py X-VCS-Directories: main/trunk/pym/portage X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico Content-Type: text/plain; charset=UTF-8 Message-Id: Sender: Zac Medico Date: Sat, 07 Mar 2009 00:05:31 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: b65c85d5-4b93-431d-bf55-59bb850b4123 X-Archives-Hash: 8eee52ad3be358a8e5c41e58269b0f6b Author: zmedico Date: 2009-03-07 00:05:30 +0000 (Sat, 07 Mar 2009) New Revision: 12772 Modified: main/trunk/pym/portage/util.py Log: Fix LazyItemsDict.update() to create new _SingletonWrapper instances that reference self. Modified: main/trunk/pym/portage/util.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/trunk/pym/portage/util.py 2009-03-06 20:50:53 UTC (rev 12771) +++ main/trunk/pym/portage/util.py 2009-03-07 00:05:30 UTC (rev 12772) @@ -1082,8 +1082,8 @@ """This is like addLazyItem except value_callable will only be called a maximum of 1 time and the result will be cached for future requests.= """ self.addLazyItem(item_key, - self._SingletonWrapper(self, item_key, value_callable, - *pargs, **kwargs)) + self._SingletonWrapper(self, item_key, value_callable), + *pargs, **kwargs) =20 def update(self, *args, **kwargs): if len(args) > 1: @@ -1102,7 +1102,12 @@ dict.__setitem__(self, k, None) else: dict.__setitem__(self, k, map_obj[k]) - self.lazy_items.update(map_obj.lazy_items) + for k, v in map_obj.lazy_items.iteritems(): + if isinstance(v[0], self._SingletonWrapper): + # Create a new wrapper that references self. + v =3D (self._SingletonWrapper(self, k, v[0]._callable), + v[1], v[2]) + self.lazy_items[k] =3D v else: dict.update(self, map_obj) if kwargs: @@ -1182,17 +1187,15 @@ =20 class _SingletonWrapper(object): =20 - __slots__ =3D ('_parent', '_key', '_callable', '_pargs', '_kwargs') + __slots__ =3D ('_parent', '_key', '_callable') =20 - def __init__(self, parent, key, value_callable, *pargs, **kwargs): + def __init__(self, parent, key, value_callable): self._parent =3D parent self._key =3D key self._callable =3D value_callable - self._pargs =3D pargs - self._kwargs =3D kwargs =20 - def __call__(self): - value =3D self._callable(*self._pargs, **self._kwargs) + def __call__(self, *pargs, **kwargs): + value =3D self._callable(*pargs, **kwargs) self._parent[self._key] =3D value return value =20