Fix iter example in usafe fixes doc (#22118)

## Summary

This appears to have been a copy/paste error from the list example, as
the subscript is not present in the original next/iter example only in
the case where the error case is shown. While in the specific example
code the subscript actually has no effect, it does make the example
slightly confusing.

Consider the following variations, first the example from the docs
unchanged and second the same code but not hitting the intended error
case (due to using a non-empty collection):
```console
$ python3 -c 'next(iter(range(0)))[0]'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
StopIteration

$ python3 -c 'next(iter(range(1)))[0]'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: 'int' object is not subscriptable
```

## Test Plan

Not directly tested, however see inline snippets above.
This commit is contained in:
Peter Law 2025-12-22 14:25:28 +00:00 committed by GitHub
parent 422e99ea70
commit 87406b43ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -188,7 +188,7 @@ IndexError: list index out of range
```
```console
$ python -c 'next(iter(range(0)))[0]'
$ python -c 'next(iter(range(0)))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
StopIteration