-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-33563: Fileinput(bufsize=0) does not emit deprecation warning. #6959
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change removes some existing tests. They should be restored. Even if the bufsize parameter is deprecated, the code should work with it.
It may be easier to pass bufsize=fileinput._sentinel
if you want to test the behavior with the default bufsize.
Lib/fileinput.py
Outdated
@@ -80,7 +80,9 @@ | |||
|
|||
_state = None | |||
|
|||
def input(files=None, inplace=False, backup="", bufsize=0, | |||
_sentinel=object() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spaces around =
.
Lib/test/test_fileinput.py
Outdated
remove_tempfiles(t1, t2, t3, t4) | ||
bs = None | ||
t1 = t2 = t3 = t4 = t5 = t6 = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous empty lines.
@@ -87,28 +87,35 @@ def close(self): | |||
class BufferSizesTests(unittest.TestCase): | |||
def test_buffer_sizes(self): | |||
# First, run the tests with default and teeny buffer size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests will be not ran with non-default buffer size. Please restore tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but that is useless as bufsize=
is anyway ignored. That is basically running the same exact test twice...
@@ -686,7 +702,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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please restore this assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing the Mock, the MockFileInput have a bufsize attribute, the rel FileInput does not. The goal of this test is to explicitly test that fileinput.input
is forwrding input(bufsize=...)
to FileInput(bufsize...)
which this patch does remove in order to print a warnign with the correct stack. I can change to assertIsNot though.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
3f8c983
to
33c4017
Compare
I have made the requested changes; please review again Thanks, |
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
33c4017
to
ce53052
Compare
Also duplicate the warn logic for the stacklevel to be correct both when calling the constructor directly and calling `fileinput.input`
ce53052
to
9c83496
Compare
I can probably close once #13400 goes in as it will actually remove the |
Closing as the above mentioned PR has been merged. |
Also duplicate the warn logic for the stacklevel to be correct both when
calling the constructor directly and calling
fileinput.input
https://bugs.python.org/issue33563