Author xtreak
Recipients Mariatta, cheryl.sabella, rhettinger, trey, xtreak
Date 2019-05-06.15:55:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I think this is an easy issue. The relevant code is at 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/ b/Lib/test/
index 71528223d3..81a4908dbd 100644
--- a/Lib/test/
+++ b/Lib/test/
@@ -39,6 +39,11 @@ class UserStringTest(
         # we don't fix the arguments, because UserString can't cope with it
         getattr(object, methodname)(*args)

+    def test_encode(self):
+        data = UserString("hello")
+        self.assertEqual(data.encode(encoding='utf-8'), b'hello')

 if __name__ == "__main__":
Date User Action Args
2019-05-06 15:55:10xtreaksetrecipients: + xtreak, rhettinger, Mariatta, trey, cheryl.sabella
2019-05-06 15:55:10xtreaksetmessageid: <>
2019-05-06 15:55:10xtreaklinkissue36582 messages
2019-05-06 15:55:10xtreakcreate