Author: raymond.hettinger
Date: Wed Feb  6 21:47:09 2008
New Revision: 60627

Modified:
   python/branches/py3k/Lib/_abcoll.py
Log:
Fix-up the _from_iterable() method to return instances of the subclass where it 
is used.
In its previous form, it always returned instance of frozenset which makes this 
ABC
nearly useless as a mixin.  In its new form, it needs to be able to assume that 
the
constructor will take a frozenset input.  This will usually be true.  If it is 
not,
then only one method (this one) will need to be overriden by the subclass to let
it know about the unique constructor signature.  Will add info on this to the 
docs.



Modified: python/branches/py3k/Lib/_abcoll.py
==============================================================================
--- python/branches/py3k/Lib/_abcoll.py (original)
+++ python/branches/py3k/Lib/_abcoll.py Wed Feb  6 21:47:09 2008
@@ -204,7 +204,12 @@
 
     @classmethod
     def _from_iterable(cls, it):
-        return frozenset(it)
+        '''Construct an instance of the class from any iterable input.
+
+        Must override this method if the class constructor signature
+        will not accept a frozenset for an input.
+        '''
+        return cls(frozenset(it))
 
     def __and__(self, other):
         if not isinstance(other, Iterable):
_______________________________________________
Python-3000-checkins mailing list
Python-3000-checkins@python.org
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to