where the encoded result has to be fixed. Trey, if you haven't started working on it I think it's a good first issue for sprints.
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
index 71528223d3..81a4908dbd 100644
@@ -39,6 +39,11 @@ class UserStringTest(
# we don't fix the arguments, because UserString can't cope with it
+ def test_encode(self):
+ data = UserString("hello")
+ self.assertEqual(data.encode(encoding='utf-8'), b'hello')
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
The text was updated successfully, but these errors were encountered: