Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Lib/sets.py

    r2 r388  
    5555#   improvements.
    5656
    57 from __future__ import generators
    58 try:
    59     from itertools import ifilter, ifilterfalse
    60 except ImportError:
    61     # Code to make the module run under Py2.2
    62     def ifilter(predicate, iterable):
    63         if predicate is None:
    64             def predicate(x):
    65                 return x
    66         for x in iterable:
    67             if predicate(x):
    68                 yield x
    69     def ifilterfalse(predicate, iterable):
    70         if predicate is None:
    71             def predicate(x):
    72                 return x
    73         for x in iterable:
    74             if not predicate(x):
    75                 yield x
    76     try:
    77         True, False
    78     except NameError:
    79         True, False = (0==0, 0!=0)
     57from itertools import ifilter, ifilterfalse
    8058
    8159__all__ = ['BaseSet', 'Set', 'ImmutableSet']
     
    236214        else:
    237215            little, big = other, self
    238         common = ifilter(big._data.has_key, little)
     216        common = ifilter(big._data.__contains__, little)
    239217        return self.__class__(common)
    240218
     
    261239        except AttributeError:
    262240            otherdata = Set(other)._data
    263         for elt in ifilterfalse(otherdata.has_key, selfdata):
     241        for elt in ifilterfalse(otherdata.__contains__, selfdata):
    264242            data[elt] = value
    265         for elt in ifilterfalse(selfdata.has_key, otherdata):
     243        for elt in ifilterfalse(selfdata.__contains__, otherdata):
    266244            data[elt] = value
    267245        return result
     
    288266            otherdata = Set(other)._data
    289267        value = True
    290         for elt in ifilterfalse(otherdata.has_key, self):
     268        for elt in ifilterfalse(otherdata.__contains__, self):
    291269            data[elt] = value
    292270        return result
     
    314292        if len(self) > len(other):  # Fast check for obvious cases
    315293            return False
    316         for elt in ifilterfalse(other._data.has_key, self):
     294        for elt in ifilterfalse(other._data.__contains__, self):
    317295            return False
    318296        return True
     
    323301        if len(self) < len(other):  # Fast check for obvious cases
    324302            return False
    325         for elt in ifilterfalse(self._data.has_key, other):
     303        for elt in ifilterfalse(self._data.__contains__, other):
    326304            return False
    327305        return True
     
    338316        self._binary_sanity_check(other)
    339317        return len(self) > len(other) and self.issuperset(other)
     318
     319    # We inherit object.__hash__, so we must deny this explicitly
     320    __hash__ = None
    340321
    341322    # Assorted helpers
     
    440421        self._data, = data
    441422
    442     # We inherit object.__hash__, so we must deny this explicitly
    443     __hash__ = None
    444 
    445423    # In-place union, intersection, differences.
    446424    # Subtle:  The xyz_update() functions deliberately return None,
     
    504482        if self is other:
    505483            self.clear()
    506         for elt in ifilter(data.has_key, other):
     484        for elt in ifilter(data.__contains__, other):
    507485            del data[elt]
    508486
Note: See TracChangeset for help on using the changeset viewer.