[Python-bugs-list] [ python-Bugs-592573 ] UserString is mutable via +=

noreply@sourceforge.net noreply@sourceforge.net
Thu, 08 Aug 2002 18:41:00 -0700


Bugs item #592573, was opened at 2002-08-08 07:48
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=592573&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Bernhard Herzog (bernhard)
Assigned to: Raymond Hettinger (rhettinger)
Summary: UserString is mutable via +=

Initial Comment:
UserString is mutable with augmented assignment:

Python 2.2 (#1, Jan 17 2002, 21:04:07) 
[GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import UserString
>>> s = t = UserString.UserString("abc")
>>> s += "def"
>>> s
'abcdef'
>>> t
'abcdef'
>>> 


The __iadd__ and __imul__ methods should be in the
MutableString class I think.

OTOH, nowadays the string types can be sub-classed so
that UserString behaving exactly like a builtin string
may not be that important anymore.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-08 20:41

Message:
Logged In: YES 
user_id=80475

Thanks for the review.
Committed patch as:
  UserString 1.15
  string_tests.py 1.23
  test_string.py 1.19
  test_userstring.py 1.9

Agree that it should not be backported.
Marking bug as fixed and closing.

Bernhard, thanks for the clear bug report.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-08 20:22

Message:
Logged In: YES 
user_id=6380

Hm, I think this is indeed a bug. I've never used UserString
myself nor reviewed the code. I think your patch is okay, so
go ahead in 2.3.

This will create a backwards incompatibility; I'm not sure
it's a good idea to "fix" it in 2.2.2.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-08 20:09

Message:
Logged In: YES 
user_id=80475

Patch and unittest attached for review.
Possible 2.2 release-maint candidate.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-08 12:51

Message:
Logged In: YES 
user_id=80475

Thanks for the bug report.

Will patch to bring behavior back in-line with string 
methods as promised by the docs.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=592573&group_id=5470