Commit 2e50b21
committed
newrange: handle non-numbers passed to index()
These kinds of operations failed with a TypeError when a non-numeric
value is given:
>>> None in newrange(10)
>>> newrange(10).index(None)
We now catch the initial TypeError in newrange.index() and return the
ValueError result immediately.
I also considered adding an int(value) conversion, but that isn't
consistent with the standard library's range() behavior. For example:
>> "1" in range(10)
False1 parent 8b78b5e commit 2e50b21
2 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
0 commit comments