Skip to content

Commit eda634b

Browse files
author
Matthias Bussonnier
committed
Take into account some of the review comments
1 parent f83aa1a commit eda634b

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Doc/library/fileinput.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ The following function is the primary interface of this module:
6969
for line in f:
7070
process(line)
7171

72+
.. versionchanged:: 3.2
73+
Can be used as a context manager.
74+
7275
.. versionchanged:: 3.8
7376
The keyword parameters *mode* and *openhook* are now keyword-only.
7477

75-
.. versionchanged:: 3.2
76-
Can be used as a context manager.
7778

7879
The following functions use the global state created by :func:`fileinput.input`;
7980
if there is no active state, :exc:`RuntimeError` is raised.
@@ -161,9 +162,6 @@ available for subclassing as well:
161162
process(input)
162163

163164

164-
.. versionchanged:: 3.8
165-
The keyword parameter *mode* and *openhook* are now keyword-only.
166-
167165
.. versionchanged:: 3.2
168166
Can be used as a context manager.
169167

@@ -173,6 +171,10 @@ available for subclassing as well:
173171
.. deprecated:: 3.8
174172
Support for :meth:`__getitem__` method is deprecated.
175173

174+
.. versionchanged:: 3.8
175+
The keyword parameter *mode* and *openhook* are now keyword-only.
176+
177+
176178

177179
**Optional in-place filtering:** if the keyword argument ``inplace=True`` is
178180
passed to :func:`fileinput.input` or to the :class:`FileInput` constructor, the

Lib/test/test_fileinput.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ def test_buffer_sizes(self):
9090

9191
pat = re.compile(r'LINE (\d+) OF FILE (\d+)')
9292

93-
start = 1
9493
if verbose:
95-
print('%s. Simple iteration' % (start+0))
94+
print('1. Simple iteration')
9695
fi = FileInput(files=(t1, t2, t3, t4))
9796
lines = list(fi)
9897
fi.close()
@@ -103,7 +102,7 @@ def test_buffer_sizes(self):
103102
self.assertEqual(fi.filename(), t4)
104103

105104
if verbose:
106-
print('%s. Status variables' % (start+1))
105+
print('2. Status variables')
107106
fi = FileInput(files=(t1, t2, t3, t4))
108107
s = "x"
109108
while s and s != 'Line 6 of file 2\n':
@@ -115,14 +114,14 @@ def test_buffer_sizes(self):
115114
self.assertFalse(fi.isstdin())
116115

117116
if verbose:
118-
print('%s. Nextfile' % (start+2))
117+
print('3. Nextfile')
119118
fi.nextfile()
120119
self.assertEqual(fi.readline(), 'Line 1 of file 3\n')
121120
self.assertEqual(fi.lineno(), 22)
122121
fi.close()
123122

124123
if verbose:
125-
print('%s. Stdin' % (start+3))
124+
print('4. Stdin')
126125
fi = FileInput(files=(t1, t2, t3, t4, '-'))
127126
savestdin = sys.stdin
128127
try:
@@ -136,7 +135,7 @@ def test_buffer_sizes(self):
136135
sys.stdin = savestdin
137136

138137
if verbose:
139-
print('%s. Boundary conditions' % (start+4))
138+
print('5. Boundary conditions')
140139
fi = FileInput(files=(t1, t2, t3, t4))
141140
self.assertEqual(fi.lineno(), 0)
142141
self.assertEqual(fi.filename(), None)
@@ -145,7 +144,7 @@ def test_buffer_sizes(self):
145144
self.assertEqual(fi.filename(), None)
146145

147146
if verbose:
148-
print('%s. Inplace' % (start+5))
147+
print('6. Inplace')
149148
savestdout = sys.stdout
150149
try:
151150
fi = FileInput(files=(t1, t2, t3, t4), inplace=1)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:func:`fileinput.input` and :class:`fileinput.FileInput` **bufsize**
2+
argument has been removed (was deprecated and ignored since Python 3.6),
3+
and as a result the **mode** and **openhook** arguments have been made
4+
keyword-only.

0 commit comments

Comments
 (0)