[issue10221] {}.pop('a') raises non-standard KeyError exception
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Raymond, Did you mean to exclude unit test additions from your commit? See issue10221-with-tests.diff. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: We don't usually test the content of error messages because they are not a guaranteed behavior. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Mon, Nov 1, 2010 at 2:13 PM, Raymond Hettinger rep...@bugs.python.org wrote: .. We don't usually test the content of error messages because they are not a guaranteed behavior. I recall that when I asked about this on #python-dev, someone pointed to places where content of error messages is tested in python unit tests. I also asked whether such tests should be marked as cpython details, and the answer was know. Unfortunately I don't remember who was telling me that, but it sounded reasonable enough that I submitted the tests. I think if testing error messages is a grey area, in this case it is reasonable to have a test for at least two reasons: 1. It was reported as a bug, so users already expect this behavior. 2. There is no prose in the error message, just the key, so it is not as arbitrary as other error messages. Note that in my tests I deliberately tested only e.args[0] and not str(e) or e.args[1:]. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: See r85967, r85968 and r85969. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
New submission from Dirkjan Ochtman dirk...@ochtman.nl: d...@miles ~ $ python2.7 Python 2.7 (r27:82500, Oct 4 2010, 10:01:41) [GCC 4.3.4] on linux2 Type help, copyright, credits or license for more information. {}.pop('a') Traceback (most recent call last): File stdin, line 1, in module KeyError: 'pop(): dictionary is empty' {'a': 'b'}.pop('c') Traceback (most recent call last): File stdin, line 1, in module KeyError: 'c' IMO the former exception should be in line with normal KeyErrors. -- messages: 119778 nosy: djc priority: normal severity: normal status: open title: {}.pop('a') raises non-standard KeyError exception ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Dirkjan Ochtman dirk...@ochtman.nl: -- components: +Interpreter Core versions: +Python 2.6, Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +rhettinger type: - behavior versions: +Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: There have been several requests for KeyError to grow key attribute that will always contain the key that caused the error. See issue 1182143, for example. If this is done, I think it would be natural to unify the args as well for empty and non-empy case. Without adding key access API, however, I am at most -0 on changing the error message. Traditionally, the error messages are not considered part of language specification, so this is not a bug. -- nosy: +belopolsky type: behavior - feature request versions: -Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I agree with the OP's request. d.pop(k) is conceptually equivalent to: r = d[k]# raises KeyError(k) del d[k] return r The current message was probably borrowed from dict.popitem(). But that is much different since the dict.pop(k) method is key-specific (instead of size related). This fix should be backported (as it doesn't change guaranteed behaviors but does improve the debugability). -- assignee: - rhettinger stage: - needs patch versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: This is the case where fixing an issue is easier than arguing that it is not a bug. :-) (Changing to behavior not because I agree that it is a bug, but for consistency with targeting 2.7) A (1-line) patch attached. -- keywords: +patch stage: needs patch - unit test needed type: feature request - behavior Added file: http://bugs.python.org/file19400/issue10221.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Attaching a patch with tests. -- keywords: +needs review resolution: - accepted stage: unit test needed - commit review Added file: http://bugs.python.org/file19401/issue10221-with-tests.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I wonder if it would be worthwhile to unify missing key processing as in issue10221a-with-tests.diff. -- Added file: http://bugs.python.org/file19402/issue10221a-with-tests.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- resolution: accepted - stage: commit review - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10221 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com