[issue4069] set.remove raises confusing KeyError

2008-10-07 Thread Carl Friedrich Bolz

New submission from Carl Friedrich Bolz [EMAIL PROTECTED]:

When trying to remove a set from a set, the KeyError that is raised is
confusing:

Python 2.6 (r26:66714, Oct  7 2008, 13:23:57)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type help, copyright, credits or license for more information.
 s = set([frozenset([1, 2]), frozenset([2, 3])])
 s.remove(set([3, 4]))
Traceback (most recent call last):
  File stdin, line 1, in module
KeyError: frozenset([])


I understand that s.remove(set(...)) turns the set into a frozenset, but
I was expecting this converted frozenset to be attached to the KeyError,
not an empty set.

--
components: Interpreter Core
messages: 74461
nosy: cfbolz
severity: normal
status: open
title: set.remove raises confusing KeyError
type: behavior
versions: Python 2.5, Python 2.6

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4069
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4069] set.remove raises confusing KeyError

2008-10-07 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

The KeyError initially contains the correct frozenset, but its content
is swapped with the original set object (yes, like C++ std::set::swap(),
this mutates the frozenset!).

Attached a patch with unit test. The exception now shows the original key:
KeyError: {3, 4}

--
keywords: +needs review, patch
nosy: +amaury.forgeotdarc
Added file: http://bugs.python.org/file11733/set_remove.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4069
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4069] set.remove raises confusing KeyError

2008-10-07 Thread Raymond Hettinger

Changes by Raymond Hettinger [EMAIL PROTECTED]:


--
assignee:  - rhettinger
nosy: +rhettinger

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4069
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4069] set.remove raises confusing KeyError

2008-10-07 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

Patch looks fine.  I see no need to backport to 2.5 though.

--
assignee: rhettinger - amaury.forgeotdarc
keywords:  -needs review
resolution:  - accepted

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4069
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4069] set.remove raises confusing KeyError

2008-10-07 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

Committed r66836 (trunk) and r66837 (2.6).
This will merge nicely into py3k.

Hello Carl Friedrich, and thanks for the report!

--
resolution: accepted - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4069
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com