Changeset 1009:1817b6413cb4


Ignore:
Timestamp:
Jan 2, 2011, 12:57:22 PM (11 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Updated checks in __init__ to comply with original lrucache module.

Now all the original unit tests pass again.

I had thought I had maintained consistency with the tests all the
time, but it seems I forgot to run the original tests for lruchache.py
after some change in the ftputil tree.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lrucache.py

    r1008 r1009  
    4545# the suffix after the hyphen denotes modifications by the
    4646#  ftputil project with respect to the original version
    47 __version__ = "0.2-3"
     47__version__ = "0.2-4"
    4848__all__ = ['CacheKeyError', 'LRUCache', 'DEFAULT_SIZE']
    4949__docformat__ = 'reStructuredText en'
     
    127127    def __init__(self, size=DEFAULT_SIZE):
    128128        # Check arguments
    129         if size < 0:
    130             raise ValueError("cache size (%d) mustn't be negative" % size)
     129        if not isinstance(size, (int, long)):
     130            raise TypeError("cache size (%r) must be an integer" % size)
     131        if size <= 0:
     132            raise ValueError("cache size (%d) must be positive" % size)
    131133        object.__init__(self)
    132134        self.__heap = []
Note: See TracChangeset for help on using the changeset viewer.