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
collections.UserString encode method returns a string #80763
Comments
It looks like the encode method for UserString incorrectly wraps its return value in a str call.
|
Trey, would you like to submit a PR to fix this? (Be sure to add a test case). |
I think this is an easy issue. The relevant code is at cpython/Lib/collections/__init__.py Line 1210 in cec0184
A simple unittest patch that fails on master. This can have additional tests with both encoding and errors present and both of them absent hitting all three code paths in the function. diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py + def test_encode(self): if __name__ == "__main__":
unittest.main() |
I'll pick this up in the PyCon US 2019 sprint this afternoon. |
I will pick this on up |
My mistake, dfortunov is already working on this one. |
PR submitted here: Rather than adding three different tests for the different code paths I chose to collapse the three different code paths by surfacing the underlying str.encode() defaults in the method signature of UserString.encode(), taking it down to a one-line implementation. @XTreak: Thanks for the super-helpful triage and failing test case! |
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: