Helper function to convert a slice argument to an integer, and raise TypeError with a suitable message on failure.
(arg)
| 12 | |
| 13 | |
| 14 | def evaluate_slice_index(arg): |
| 15 | """ |
| 16 | Helper function to convert a slice argument to an integer, and raise |
| 17 | TypeError with a suitable message on failure. |
| 18 | |
| 19 | """ |
| 20 | if hasattr(arg, '__index__'): |
| 21 | return operator.index(arg) |
| 22 | else: |
| 23 | raise TypeError( |
| 24 | "slice indices must be integers or " |
| 25 | "None or have an __index__ method") |
| 26 | |
| 27 | def slice_indices(slice, length): |
| 28 | """ |
no test coverage detected
searching dependent graphs…