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 <1557158110.51.0.144260396208.issue36582@roundup.psfhosted.org>
In-reply-to
Content
I think this is an easy issue. The relevant code is at https://github.com/python/cpython/blob/cec01849f142ea96731b4725975b89d3af757656/Lib/collections/__init__.py#L1210 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
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -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__":
     unittest.main()
History
Date User Action Args
2019-05-06 15:55:10xtreaksetrecipients: + xtreak, rhettinger, Mariatta, trey, cheryl.sabella
2019-05-06 15:55:10xtreaksetmessageid: <1557158110.51.0.144260396208.issue36582@roundup.psfhosted.org>
2019-05-06 15:55:10xtreaklinkissue36582 messages
2019-05-06 15:55:10xtreakcreate