mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-9372: Deprecate several __getitem__ methods (GH-8609)
The __getitem__ methods of DOMEventStream, FileInput, and FileWrapper classes ignore their 'index' parameters and return the next item instead.
This commit is contained in:
parent
423d05f6f5
commit
84a13fbda0
12 changed files with 82 additions and 0 deletions
|
@ -259,6 +259,13 @@ class FileInput:
|
|||
# repeat with next file
|
||||
|
||||
def __getitem__(self, i):
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"Support for indexing FileInput objects is deprecated. "
|
||||
"Use iterator protocol instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
if i != self.lineno():
|
||||
raise RuntimeError("accessing lines out of order")
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue