Commits

Yuji Hanamura committed dbd6af0

Added the index error check for WeekDb.

Comments (0)

Files changed (1)

         if isinstance(x, basestring):
             x = int(x)
 
+        if not isinstance(x, int):
+            raise TypeError('indices must be integers or str that contains only numbers')
+
+        if x < 0:
+            x = len(self.__week_db) +  x + 1
+
+        if x <= 0 or x > len(self.__week_db):
+            raise IndexError('index out of range')
+
         return self.__week_db[x]