python / cpython

The Python programming language
https://www.python.org/
Other
60.06k stars 29.08k forks source link

Two Compensating bugs in UserString.__imul__ #33399

Closed 50eff062-408a-4098-b1b2-8222303b9d0c closed 23 years ago

50eff062-408a-4098-b1b2-8222303b9d0c commented 23 years ago
BPO 217745
Nosy @gvanrossum

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = created_at = labels = ['library'] title = 'Two Compensating bugs in UserString.__imul__' updated_at = user = 'https://bugs.python.org/anonymous' ``` bugs.python.org fields: ```python activity = actor = 'gvanrossum' assignee = 'none' closed = True closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'anonymous' dependencies = [] files = [] hgrepos = [] issue_num = 217745 keywords = [] message_count = 2.0 messages = ['2171', '2172'] nosy_count = 1.0 nosy_names = ['gvanrossum'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue217745' versions = [] ```

3772858d-27d8-44b0-a664-d68674859f36 commented 23 years ago

In UserString.py from the library, the method "__imul" is mis-spelled as "__imull" (extra L). This turns out to be a good thing, since the method uses "+=" on the data member, a string, where what is intended is apparently "*=". The class seems to work, I presume, because, since the interpreter can't find a method __imul, it does the multiplication and re-assignment itself. But: import UserString a=UserString.UserString("foo") a.__imull(3) produces a suitable error.

gvanrossum commented 23 years ago

Thanks! Fixed now.