-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
allow argparse FileType to accept encoding and errors arguments #55384
Comments
Suggestion from a personal email: Allow FileType to accept encoding and errors arguments |
The encoding and errors arguments are probably useful, but why would you use the codecs module? |
Probably because the suggestion came from someone thinking about both Python 2 and 3. But given that this feature request can only target Python 3.3, you're absolutely right that there's no need to go through the codecs module. |
Here's an attempt at implementing this (my first contribution). Some notes:
|
Lucas: You only added tests for the repr, you should probably test the actual new functionality, too. |
OK, as discussed offline with Petri I'll put some tests to ensure that open() is called the right way (using unittest.mock.patch). |
Alright, here's a version with more tests (unittest.mock is awesome!). I think it tests exactly what it should (and no more), i.e. that the arguments are correctly passed to |
LGTM. Let's wait for Steven's comments as he's the maintainer of argparse. |
Is there something I can do something to move this forward? |
Since Steven is not responding, I think I can commit it at some point. Thanks for the remainder :) |
The patch needs documentation, though, right? http://docs.python.org/dev/library/argparse.html#filetype-objects |
Right, good point. Lucas, could you fix the documentation too? |
OK, I'll give it a try. |
Added some documentation for the patch. Let me know what you think. |
As per Ezio's comment, changed "l1" to "utf-8" in the example of the doc. |
New changeset d5a0698a8354 by Petri Lehtinen in branch 'default': |
Committed, thanks for the patch! I made little tweaks before committing:
|
Sorry for the little glitches you had to fix, I wonder why I didn't catch them. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: