[issue2651] Strings passed to KeyError do not round trip

2020-09-11 Thread Anthony Sottile
Anthony Sottile added the comment: (I know this is old and closed but I've just run into the same thing with pwd.getpwnam in issue41767) KeyError: "getpwnam(): name not found: 'test'" would it be possible / make sense to extend `KeyError` with a named-only-argument which would preserve th

[issue2651] Strings passed to KeyError do not round trip

2018-08-08 Thread Łukasz Langa
Łukasz Langa added the comment: I agree with Inadasan. I was eager to fix this until I actually got to it at the '16 core sprint. I think there's too little value in fixing this versus possible backwards compatibility breakage. -- resolution: -> wont fix stage: patch review -> resolv

[issue2651] Strings passed to KeyError do not round trip

2018-07-27 Thread INADA Naoki
INADA Naoki added the comment: Even if we fixed stdlib, there are many KeyError(missing) idiom used in 3rd party code. KeyError: '42' KeyError: '42\n' KeyError: 42 All of the above are looks different. I think it's good. Is it really worth enough to break it? -- nosy: +inada.naoki

[issue2651] Strings passed to KeyError do not round trip

2018-07-27 Thread Ben Doremus
Ben Doremus added the comment: Did this patch die? I ran into the same issue noted in the SO post. It's bizarre that KeyError is the only error message to handle things this way. -- nosy: +bdoremus ___ Python tracker

[issue2651] Strings passed to KeyError do not round trip

2017-10-23 Thread Terry J. Reedy
Terry J. Reedy added the comment: A new Stackoverflow question gives a better illustration of how special-casing KeyError can be a nuisance. https://stackoverflow.com/questions/46892261/new-line-on-error-message-in-idle-python-3-3/46899120#46899120 >From a current repository build instead of 3.

[issue2651] Strings passed to KeyError do not round trip

2016-09-09 Thread Łukasz Langa
Łukasz Langa added the comment: So actually the issue long predates Python 2.5... https://hg.python.org/cpython/rev/0401a0ead1eb Now I'm not so sure it's worth touching it anymore ;) -- ___ Python tracker

[issue2651] Strings passed to KeyError do not round trip

2016-09-07 Thread Antoine Pitrou
Antoine Pitrou added the comment: > No, the suggestion is to only adopt the first part of the patch from 2010, > which is to revert KeyError to behave like LookupError again That ship has sailed long ago. 2.7, 3.4 and 3.5 (the three major Python versions currently in use) all have the same beh

[issue2651] Strings passed to KeyError do not round trip

2016-09-07 Thread Łukasz Langa
Łukasz Langa added the comment: No, the suggestion is to only adopt the first part of the patch from 2010, which is to revert KeyError to behave like LookupError again: >>> print(LookupError('key')) key >>> print(KeyError('key'), 'now') 'key' now >>> print(KeyError('key'), 'in 3.6')

[issue2651] Strings passed to KeyError do not round trip

2016-09-07 Thread Antoine Pitrou
Antoine Pitrou added the comment: What are you suggesting? Something like: KeyError: key 'foobar' not found in dict ? If so, +1 from me. -- ___ Python tracker ___

[issue2651] Strings passed to KeyError do not round trip

2016-09-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: The current behavior seems to be a recurring source of confusion and bugs, so something needs to change. I'm thinking that the least egregious thing to do is to remove (in 3.6) the special case code for KeyError. The small downside is that KeyError('') w

[issue2651] Strings passed to KeyError do not round trip

2015-09-04 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue2651] Strings passed to KeyError do not round trip

2015-09-04 Thread Łukasz Langa
Changes by Łukasz Langa : -- versions: +Python 3.6 -Python 3.5 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue2651] Strings passed to KeyError do not round trip

2015-04-30 Thread Łukasz Langa
Łukasz Langa added the comment: Agreed that this can be addressed now for Python 3.5. -- assignee: -> lukasz.langa versions: +Python 3.5 -Python 3.2, Python 3.3 ___ Python tracker __

[issue2651] Strings passed to KeyError do not round trip

2015-04-11 Thread Martin Panter
Martin Panter added the comment: The moratorium is over as far as I understand, and PEP 3151 (OSError changes) has already been implemented. My understanding is that exception messages are not generally part of the API. I think that avoiding this surprising quirk is more important than retaini

[issue2651] Strings passed to KeyError do not round trip

2012-02-22 Thread David
David added the comment: I'm +1 for fixing this behavior for the same reasons that are mentioned in the OP: consistency and predictability. I raised this issue as #14086, and I was referred to this issue before closing mine as a duplicate. It took me a while to figure out why I was getting un

[issue2651] Strings passed to KeyError do not round trip

2011-12-02 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: -BreamoreBoy versions: +Python 3.3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue2651] Strings passed to KeyError do not round trip

2011-08-18 Thread Julian Berman
Changes by Julian Berman : -- nosy: +Julian ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue2651] Strings passed to KeyError do not round trip

2011-08-18 Thread Meador Inge
Changes by Meador Inge : -- stage: needs patch -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue2651] Strings passed to KeyError do not round trip

2010-08-08 Thread Łukasz Langa
Łukasz Langa added the comment: For the record, I am -1 for this change after discussion on #python-dev. There are three major arguments against the proposed approach: 1. Moratorium. If we don't stick to the rules set by ourselves, nobody will take us seriously. No exceptions, this has to wai

[issue2651] Strings passed to KeyError do not round trip

2010-08-05 Thread Brett Cannon
Changes by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue2651] Strings passed to KeyError do not round trip

2010-08-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Unassigning because others seem to be ahead of me reviewing this patch. I will keep an eye on this, though. Please note that I marked issue #614557 to depend on this one. Adding 'key' attribute to exceptions is the subject of that issue. While I sup

[issue2651] Strings passed to KeyError do not round trip

2010-08-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: Latest patch looks good. Note that you could use PyUnicode_FromFormat() instead of building the format string manually. -- ___ Python tracker _

[issue2651] Strings passed to KeyError do not round trip

2010-08-04 Thread Łukasz Langa
Łukasz Langa added the comment: FTR regarding for Antoine's comment above: that code should in fact be removed :) -- ___ Python tracker ___ _

[issue2651] Strings passed to KeyError do not round trip

2010-08-04 Thread Łukasz Langa
Łukasz Langa added the comment: Patch updated to include a roundtrip test in test_exceptions. -- Added file: http://bugs.python.org/file18372/issue2651.diff ___ Python tracker __

[issue2651] Strings passed to KeyError do not round trip

2010-08-04 Thread Łukasz Langa
Changes by Łukasz Langa : Removed file: http://bugs.python.org/file18371/issue2651.diff ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue2651] Strings passed to KeyError do not round trip

2010-08-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: In KeyError_str, I think the following code shouldn't be deleted: -if (PyTuple_GET_SIZE(self->args) == 1) { -return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0)); -- ___ Python tracker

[issue2651] Strings passed to KeyError do not round trip

2010-08-03 Thread Łukasz Langa
Łukasz Langa added the comment: Corrected patch attached. You're right, I left in ReST doc changes for configparser. Sorry for that. -- Added file: http://bugs.python.org/file18371/issue2651.diff ___ Python tracker

[issue2651] Strings passed to KeyError do not round trip

2010-08-03 Thread Łukasz Langa
Changes by Łukasz Langa : Removed file: http://bugs.python.org/file18356/issue2651.diff ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue2651] Strings passed to KeyError do not round trip

2010-08-03 Thread Éric Araujo
Éric Araujo added the comment: Looks like you didn’t narrow your diff command, since unrelated changes to configparser appear there. svn diff file1 path/file2 :) -- nosy: +merwok ___ Python tracker ___

[issue2651] Strings passed to KeyError do not round trip

2010-08-03 Thread Łukasz Langa
Łukasz Langa added the comment: Patch for py3k ready. Includes patches for the stdlib where tests actually failed. -- Added file: http://bugs.python.org/file18356/issue2651.diff ___ Python tracker

[issue2651] Strings passed to KeyError do not round trip

2010-07-25 Thread Mark Lawrence
Mark Lawrence added the comment: @Łukasz: please provide an updated patch. -- nosy: +BreamoreBoy stage: -> needs patch ___ Python tracker ___ ___

[issue2651] Strings passed to KeyError do not round trip

2010-07-23 Thread Łukasz Langa
Łukasz Langa added the comment: Alexander, Brett, I could update the patch but first I need thumbs up that this is going to be accepted and some eventual code breaks will be patched (again, I can do that but it has to be accepted on time). Brett, what to do? -- nosy: +brett.cannon, l

[issue2651] Strings passed to KeyError do not round trip

2010-06-08 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: KeyError.patch is out of date. Is anyone motivated enough to update it for py3k? I like the idea, but don't have spare cycles at the moment. -- ___ Python tracker

[issue2651] Strings passed to KeyError do not round trip

2010-05-27 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- versions: +Python 3.2 -Python 2.5 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue2651] Strings passed to KeyError do not round trip

2010-05-27 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: -> belopolsky nosy: +belopolsky ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue2651] Strings passed to KeyError do not round trip

2008-05-08 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Wouldn't it be nice to also store the offending key as a "key" attribute? Writing key_error.key is a lot intuitive than key_error.args[0] (or is it key_error.args[1] ? I've already forgotten :-)). -- nosy: +pitrou ___

[issue2651] Strings passed to KeyError do not round trip

2008-04-20 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Attached patch changes KeyError: when it has two arguments, they are formatted with "%s: %r". Otherwise the base repr is called, and this allows the round trip. Standard objects (dict, set, UserDict, namedtuple, defaultdict, weak dictio

[issue2651] Strings passed to KeyError do not round trip

2008-04-18 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Here is another form of the same inconsistency: >>> [].pop(0) IndexError: pop from empty list >>> {}.pop(0) KeyError: 'pop(): dictionary is empty' And my preferred one: >>> unicodedata.lookup('"') KeyError: 'undefined character name \'

[issue2651] Strings passed to KeyError do not round trip

2008-04-17 Thread Rick Harris
Rick Harris <[EMAIL PROTECTED]> added the comment: I think it is important to round-trip for at least two reasons: 1) Consistency. Other built-in exceptions behave this way, why should KeyError be any different? Okay, technically 3 UnicodeErrors don't allow just strings to be passed in (perhaps

[issue2651] Strings passed to KeyError do not round trip

2008-04-17 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Here is a relevant comment inside the KeyError_str function: /* If args is a tuple of exactly one item, apply repr to args[0]. This is done so that e.g. the exception raised by {}[''] prints KeyError: '' rather

[issue2651] Strings passed to KeyError do not round trip

2008-04-17 Thread Rick Harris
New submission from Rick Harris <[EMAIL PROTECTED]>: Here is a bug in Python 2.5 which would be nice to fix for Py3k (since we are already breaking compatibility): Take a string: s = "Hello" Create a KeyError exception with that string: e = KeyError(s) Counterintuitively, casting the exception