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/abc.py

    r2 r388  
    33
    44"""Abstract Base Classes (ABCs) according to PEP 3119."""
     5
     6import types
     7
     8from _weakrefset import WeakSet
     9
     10# Instance of old-style class
     11class _C: pass
     12_InstanceType = type(_C())
    513
    614
     
    8997        cls.__abstractmethods__ = frozenset(abstracts)
    9098        # Set up inheritance registry
    91         cls._abc_registry = set()
    92         cls._abc_cache = set()
    93         cls._abc_negative_cache = set()
     99        cls._abc_registry = WeakSet()
     100        cls._abc_cache = WeakSet()
     101        cls._abc_negative_cache = WeakSet()
    94102        cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
    95103        return cls
     
    97105    def register(cls, subclass):
    98106        """Register a virtual subclass of an ABC."""
    99         if not isinstance(cls, type):
     107        if not isinstance(subclass, (type, types.ClassType)):
    100108            raise TypeError("Can only register classes")
    101109        if issubclass(subclass, cls):
     
    122130        # Inline the cache checking when it's simple.
    123131        subclass = getattr(instance, '__class__', None)
    124         if subclass in cls._abc_cache:
     132        if subclass is not None and subclass in cls._abc_cache:
    125133            return True
    126134        subtype = type(instance)
     135        # Old-style instances
     136        if subtype is _InstanceType:
     137            subtype = subclass
    127138        if subtype is subclass or subclass is None:
    128139            if (cls._abc_negative_cache_version ==
     
    143154        if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
    144155            # Invalidate the negative cache
    145             cls._abc_negative_cache = set()
     156            cls._abc_negative_cache = WeakSet()
    146157            cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
    147158        elif subclass in cls._abc_negative_cache:
Note: See TracChangeset for help on using the changeset viewer.