[Python-checkins] CVS: python/dist/src/Lib weakref.py,1.7,1.8

Fred L. Drake fdrake@users.sourceforge.net
Mon, 16 Apr 2001 10:34:50 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv30615

Modified Files:
	weakref.py 
Log Message:

Weak*Dictionary.update():  Fix calls to [].append() to only have one
    parameter.

Weak*Dictionary.get():  Make the second parameter optional.

WeakKeyDictionary.has_key(), .keys():  Make these actually work!


Index: weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** weakref.py	2001/04/10 19:11:23	1.7
--- weakref.py	2001/04/16 17:34:48	1.8
***************
*** 55,59 ****
          return new
  
!     def get(self, key, default):
          try:
              ref = self.data[key]
--- 55,59 ----
          return new
  
!     def get(self, key, default=None):
          try:
              ref = self.data[key]
***************
*** 101,105 ****
              def remove(o, data=d, key=key):
                  del data[key]
!             L.append(key, ref(o, remove))
          for key, r in L:
              d[key] = r
--- 101,105 ----
              def remove(o, data=d, key=key):
                  del data[key]
!             L.append((key, ref(o, remove)))
          for key, r in L:
              d[key] = r
***************
*** 140,146 ****
          return new
  
!     def get(self, key, default):
          return self.data.get(ref(key),default)
  
      def items(self):
          L = []
--- 140,149 ----
          return new
  
!     def get(self, key, default=None):
          return self.data.get(ref(key),default)
  
+     def has_key(self, key):
+         return self.data.has_key(ref(key))
+ 
      def items(self):
          L = []
***************
*** 151,154 ****
--- 154,165 ----
          return L
  
+     def keys(self):
+         L = []
+         for ref in self.data.keys():
+             o = ref()
+             if o is not None:
+                 L.append(o)
+         return L
+ 
      def popitem(self):
          while 1:
***************
*** 165,169 ****
          L = []
          for key, value in dict.items():
!             L.append(ref(key, self._remove), value)
          for key, r in L:
              d[key] = r
--- 176,180 ----
          L = []
          for key, value in dict.items():
!             L.append((ref(key, self._remove), value))
          for key, r in L:
              d[key] = r