From 84a13fbda0d79789e3c9efcc9f64752261ce1e8d Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sat, 11 Aug 2018 09:05:04 +0300 Subject: 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. --- Lib/fileinput.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/fileinput.py') diff --git a/Lib/fileinput.py b/Lib/fileinput.py index c6fc9a1981a..a7f8df37aad 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -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: -- cgit v1.2.3