[Python-bugs-list] [ python-Bugs-592573 ] UserString is mutable via +=
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 08 Aug 2002 18:22:27 -0700
Bugs item #592573, was opened at 2002-08-08 08: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: Open
>Resolution: Accepted
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: Guido van Rossum (gvanrossum)
Date: 2002-08-08 21: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 21: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 13: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