-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-36952: remove bufsize keyword (deprecated 3.6, removed 3.8) #13400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
serhiy-storchaka
merged 7 commits into
python:master
from
Carreau:remove-deprecated-bufsize
May 20, 2019
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
243d68c
bpo-36952: remove bufsize keyword (deprecated 3.6, removed 3.8)
Carreau 2853aaa
Mention Contributor in whatsnew
1884bc1
make parameters kwonly
57f4a55
Simplify tests to reflect new removed parameter
beafa19
fix whitespaces
f83aa1a
plural
Carreau eda634b
Take into account some of the review comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -821,6 +821,10 @@ The following features and APIs have been removed from Python 3.8: | |
exposed to the user. | ||
(Contributed by Aviv Palivoda in :issue:`30262`.) | ||
|
||
* The ``bufsize`` keyword argument of :func:`fileinput.input` and | ||
:func:`fileinput.FileInput` which was ignored and deprecated since Python 3.6 | ||
has been removed. :issue:`36952` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add "(Contributed by ...)" as in other entries. |
||
|
||
|
||
Porting to Python 3.8 | ||
===================== | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,24 +83,20 @@ def close(self): | |
class BufferSizesTests(BaseTests, unittest.TestCase): | ||
def test_buffer_sizes(self): | ||
# First, run the tests with default and teeny buffer size. | ||
for round, bs in (0, 0), (1, 30): | ||
for round in (0, 1): | ||
Carreau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
t1 = self.writeTmp(''.join("Line %s of file 1\n" % (i+1) for i in range(15))) | ||
t2 = self.writeTmp(''.join("Line %s of file 2\n" % (i+1) for i in range(10))) | ||
t3 = self.writeTmp(''.join("Line %s of file 3\n" % (i+1) for i in range(5))) | ||
t4 = self.writeTmp(''.join("Line %s of file 4\n" % (i+1) for i in range(1))) | ||
if bs: | ||
with self.assertWarns(DeprecationWarning): | ||
self.buffer_size_test(t1, t2, t3, t4, bs, round) | ||
else: | ||
self.buffer_size_test(t1, t2, t3, t4, bs, round) | ||
self.buffer_size_test(t1, t2, t3, t4, round) | ||
Carreau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def buffer_size_test(self, t1, t2, t3, t4, bs=0, round=0): | ||
def buffer_size_test(self, t1, t2, t3, t4, round=0): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
pat = re.compile(r'LINE (\d+) OF FILE (\d+)') | ||
|
||
start = 1 + round*6 | ||
if verbose: | ||
print('%s. Simple iteration (bs=%s)' % (start+0, bs)) | ||
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) | ||
print('%s. Simple iteration' % (start+0)) | ||
fi = FileInput(files=(t1, t2, t3, t4)) | ||
lines = list(fi) | ||
fi.close() | ||
self.assertEqual(len(lines), 31) | ||
|
@@ -110,8 +106,8 @@ def buffer_size_test(self, t1, t2, t3, t4, bs=0, round=0): | |
self.assertEqual(fi.filename(), t4) | ||
|
||
if verbose: | ||
print('%s. Status variables (bs=%s)' % (start+1, bs)) | ||
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) | ||
print('%s. Status variables' % (start+1)) | ||
fi = FileInput(files=(t1, t2, t3, t4)) | ||
s = "x" | ||
while s and s != 'Line 6 of file 2\n': | ||
s = fi.readline() | ||
|
@@ -122,15 +118,15 @@ def buffer_size_test(self, t1, t2, t3, t4, bs=0, round=0): | |
self.assertFalse(fi.isstdin()) | ||
|
||
if verbose: | ||
print('%s. Nextfile (bs=%s)' % (start+2, bs)) | ||
print('%s. Nextfile' % (start+2)) | ||
fi.nextfile() | ||
self.assertEqual(fi.readline(), 'Line 1 of file 3\n') | ||
self.assertEqual(fi.lineno(), 22) | ||
fi.close() | ||
|
||
if verbose: | ||
print('%s. Stdin (bs=%s)' % (start+3, bs)) | ||
fi = FileInput(files=(t1, t2, t3, t4, '-'), bufsize=bs) | ||
print('%s. Stdin' % (start+3)) | ||
fi = FileInput(files=(t1, t2, t3, t4, '-')) | ||
savestdin = sys.stdin | ||
try: | ||
sys.stdin = StringIO("Line 1 of stdin\nLine 2 of stdin\n") | ||
|
@@ -143,27 +139,27 @@ def buffer_size_test(self, t1, t2, t3, t4, bs=0, round=0): | |
sys.stdin = savestdin | ||
|
||
if verbose: | ||
print('%s. Boundary conditions (bs=%s)' % (start+4, bs)) | ||
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) | ||
print('%s. Boundary conditions' % (start+4)) | ||
fi = FileInput(files=(t1, t2, t3, t4)) | ||
self.assertEqual(fi.lineno(), 0) | ||
self.assertEqual(fi.filename(), None) | ||
fi.nextfile() | ||
self.assertEqual(fi.lineno(), 0) | ||
self.assertEqual(fi.filename(), None) | ||
|
||
if verbose: | ||
print('%s. Inplace (bs=%s)' % (start+5, bs)) | ||
print('%s. Inplace' % (start+5)) | ||
savestdout = sys.stdout | ||
try: | ||
fi = FileInput(files=(t1, t2, t3, t4), inplace=1, bufsize=bs) | ||
fi = FileInput(files=(t1, t2, t3, t4), inplace=1) | ||
for line in fi: | ||
line = line[:-1].upper() | ||
print(line) | ||
fi.close() | ||
finally: | ||
sys.stdout = savestdout | ||
|
||
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) | ||
fi = FileInput(files=(t1, t2, t3, t4)) | ||
for line in fi: | ||
self.assertEqual(line[-1], '\n') | ||
m = pat.match(line[:-1]) | ||
|
@@ -533,12 +529,11 @@ def test_pathlib_file_inplace(self): | |
class MockFileInput: | ||
"""A class that mocks out fileinput.FileInput for use during unit tests""" | ||
|
||
def __init__(self, files=None, inplace=False, backup="", bufsize=0, | ||
def __init__(self, files=None, inplace=False, backup="", | ||
mode="r", openhook=None): | ||
self.files = files | ||
self.inplace = inplace | ||
self.backup = backup | ||
self.bufsize = bufsize | ||
self.mode = mode | ||
self.openhook = openhook | ||
self._file = None | ||
|
@@ -641,13 +636,11 @@ def do_test_call_input(self): | |
files = object() | ||
inplace = object() | ||
backup = object() | ||
bufsize = object() | ||
mode = object() | ||
openhook = object() | ||
|
||
# call fileinput.input() with different values for each argument | ||
result = fileinput.input(files=files, inplace=inplace, backup=backup, | ||
bufsize=bufsize, | ||
mode=mode, openhook=openhook) | ||
|
||
# ensure fileinput._state was set to the returned object | ||
|
@@ -658,7 +651,6 @@ def do_test_call_input(self): | |
self.assertIs(files, result.files, "files") | ||
self.assertIs(inplace, result.inplace, "inplace") | ||
self.assertIs(backup, result.backup, "backup") | ||
self.assertIs(bufsize, result.bufsize, "bufsize") | ||
self.assertIs(mode, result.mode, "mode") | ||
self.assertIs(openhook, result.openhook, "openhook") | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.