public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r12772 - main/trunk/pym/portage
@ 2009-03-07  0:05 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-03-07  0:05 UTC (permalink / raw
  To: gentoo-commits

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
===================================================================
--- 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)
 
 	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 = (self._SingletonWrapper(self, k, v[0]._callable),
+						v[1], v[2])
+				self.lazy_items[k] = v
 		else:
 			dict.update(self, map_obj)
 		if kwargs:
@@ -1182,17 +1187,15 @@
 
 	class _SingletonWrapper(object):
 
-		__slots__ = ('_parent', '_key', '_callable', '_pargs', '_kwargs')
+		__slots__ = ('_parent', '_key', '_callable')
 
-		def __init__(self, parent, key, value_callable, *pargs, **kwargs):
+		def __init__(self, parent, key, value_callable):
 			self._parent = parent
 			self._key = key
 			self._callable = value_callable
-			self._pargs = pargs
-			self._kwargs = kwargs
 
-		def __call__(self):
-			value = self._callable(*self._pargs, **self._kwargs)
+		def __call__(self, *pargs, **kwargs):
+			value = self._callable(*pargs, **kwargs)
 			self._parent[self._key] = value
 			return value
 




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-07  0:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-07  0:05 [gentoo-commits] portage r12772 - main/trunk/pym/portage Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox