decode a slice object as sent to __getitem__. takes into account the 2.5 __index__() method, basically.
(slc: slice)
| 217 | |
| 218 | |
| 219 | def decode_slice(slc: slice) -> Tuple[Any, ...]: |
| 220 | """decode a slice object as sent to __getitem__. |
| 221 | |
| 222 | takes into account the 2.5 __index__() method, basically. |
| 223 | |
| 224 | """ |
| 225 | ret: List[Any] = [] |
| 226 | for x in slc.start, slc.stop, slc.step: |
| 227 | if hasattr(x, "__index__"): |
| 228 | x = x.__index__() |
| 229 | ret.append(x) |
| 230 | return tuple(ret) |
| 231 | |
| 232 | |
| 233 | def _unique_symbols(used: Sequence[str], *bases: str) -> Iterator[str]: |