[issue36582] collections.UserString encode method returns a string

2019-08-27 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-08-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 2cb82d2a88710b0af10b9d9721a9710ecc037e72 by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.8':
bpo-36582: Make collections.UserString.encode() return bytes, not str 
(GH-13138) (GH-15557)
https://github.com/python/cpython/commit/2cb82d2a88710b0af10b9d9721a9710ecc037e72


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-08-27 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
versions: +Python 3.9 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-08-27 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15230
pull_request: https://github.com/python/cpython/pull/15557

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-08-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 2a16eea71f56c2d8f38c295c8ce71a9a9a140aff by Raymond Hettinger 
(Daniel Fortunov) in branch 'master':
bpo-36582: Make collections.UserString.encode() return bytes, not str (GH-13138)
https://github.com/python/cpython/commit/2a16eea71f56c2d8f38c295c8ce71a9a9a140aff


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread Daniel Fortunov


Daniel Fortunov  added the comment:

PR submitted here:
https://github.com/python/cpython/pull/13138

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!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread Daniel Fortunov


Change by Daniel Fortunov :


--
keywords: +patch
pull_requests: +13051
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

My mistake, dfortunov is already working on this one.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

I will pick this on up

--
nosy: +MICHAEL BLAHAY

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread Daniel Fortunov


Daniel Fortunov  added the comment:

I'll pick this up in the PyCon US 2019 sprint this afternoon.

--
nosy: +dfortunov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +easy
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

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()

--
nosy: +Mariatta, cheryl.sabella, xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-04-09 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Trey, would you like to submit a PR to fix this?  (Be sure to add a test case).

--
assignee:  -> rhettinger
type:  -> behavior
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-04-09 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36582] collections.UserString encode method returns a string

2019-04-09 Thread Trey Hunner


New submission from Trey Hunner :

It looks like the encode method for UserString incorrectly wraps its return 
value in a str call.

```
>>> from collections import UserString
>>> UserString("hello").encode('utf-8') == b'hello'
False
>>> UserString("hello").encode('utf-8')
"b'hello'"
>>> type(UserString("hello").encode('utf-8'))

```

--
components: Library (Lib)
messages: 339818
nosy: trey
priority: normal
severity: normal
status: open
title: collections.UserString encode method returns a string
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com