Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented May 17, 2018

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

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a 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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces around =.

remove_tempfiles(t1, t2, t3, t4)
bs = None
t1 = t2 = t3 = t4 = t5 = t6 = None

Copy link
Member

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.
Copy link
Member

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.

Copy link
Contributor Author

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore this assertion.

Copy link
Contributor Author

@Carreau Carreau May 18, 2018

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.

@bedevere-bot
Copy link

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Carreau Carreau force-pushed the better-bufsize-deprecation branch from 3f8c983 to 33c4017 Compare May 18, 2018 16:15
@Carreau
Copy link
Contributor Author

Carreau commented May 18, 2018

I have made the requested changes; please review again

Thanks,

@bedevere-bot
Copy link

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

@Carreau Carreau force-pushed the better-bufsize-deprecation branch from 33c4017 to ce53052 Compare May 21, 2018 21:22
Also duplicate the warn logic for the stacklevel to be correct both when
calling the constructor directly and calling `fileinput.input`
@Carreau Carreau force-pushed the better-bufsize-deprecation branch from ce53052 to 9c83496 Compare May 17, 2019 20:08
@csabella csabella requested a review from serhiy-storchaka May 17, 2019 22:10
@Carreau
Copy link
Contributor Author

Carreau commented May 20, 2019

I can probably close once #13400 goes in as it will actually remove the bufsize= parameter.

@Carreau
Copy link
Contributor Author

Carreau commented May 20, 2019

Closing as the above mentioned PR has been merged.

@Carreau Carreau closed this May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants