[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-08-23 Thread Drekin
Drekin added the comment: This patch introduces a bit ugly traceback. Shouldn't there be “raise from None” or “raise from previous_exc” instead of simple raise? -- nosy: +Drekin ___ Python tracker rep...@bugs.python.org

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-08-23 Thread STINNER Victor
STINNER Victor added the comment: This patch introduces a bit ugly traceback. Shouldn't there be “raise from None” or “raise from previous_exc” instead of simple raise? Oh, I see. os.environb[b'10'] Traceback (most recent call last): File /home/vstinner/prog/python/default/Lib/os.py, line

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-08-23 Thread Drekin
Drekin added the comment: It's also in __delitem__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17702 ___ ___ Python-bugs-list mailing list

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-08-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset 26c049dc1a4a by Victor Stinner in branch '3.3': Close #17702: On error, os.environb now removes suppress the except context http://hg.python.org/cpython/rev/26c049dc1a4a New changeset 01f33959ddf6 by Victor Stinner in branch 'default': (Merge 3.3)

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-08-23 Thread STINNER Victor
STINNER Victor added the comment: This patch introduces a bit ugly traceback. It is now fixed, thanks for the report! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17702 ___

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset 72df981e83d3 by Victor Stinner in branch '3.3': Close #17702: os.environ now raises KeyError with the original environment http://hg.python.org/cpython/rev/72df981e83d3 New changeset ea54559a4442 by Victor Stinner in branch 'default': (Merge 3.3)

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-12 Thread R. David Murray
R. David Murray added the comment: Well, it is not that it is converting it in the exception, it is that it is converting it in order to do the lookup. It is an interesting question whether or not its value in the exception should be considered a bug. -- nosy: +r.david.murray

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-12 Thread STINNER Victor
STINNER Victor added the comment: It is an interesting question whether or not its value in the exception should be considered a bug. I consider it as a bug because it is very surprising to have a different key on the error. Attached patch fixes the issue. -- keywords: +patch

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-12 Thread R. David Murray
R. David Murray added the comment: Sounds fine to me. Is there a reason you are not using 'with assertRaises' in the test? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17702 ___

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-12 Thread STINNER Victor
STINNER Victor added the comment: Is there a reason you are not using 'with assertRaises' in the test? The test is not testing the exception class, but the first argument of the exception. How do you test that using assertRaises()? Especially to check err.args[0] is missing. --

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-12 Thread R. David Murray
R. David Murray added the comment: with self.assertRaises(KeyError) as cm: os.environ[missing] self.assertEqual(cm.excecption.args[0], missing) (I don't know why assertRaises returns itself rather than just returning the exception in the with, but that's the API). --

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-11 Thread Robert Tasarz
New submission from Robert Tasarz: Minimal example: import os somekey = 'random' try: ... os.environ[somekey] ... except KeyError as e: ... print(repr(e)) ... somekey == e.args[0] ... KeyError(b'random',) False Tested in Python 3.3.1 on Debian -- components: Extension

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-11 Thread Robert Tasarz
Changes by Robert Tasarz robert.tas...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17702 ___ ___

[issue17702] os.environ converts key type from string to bytes in KeyError exception

2013-04-11 Thread Ned Deily
Changes by Ned Deily n...@acm.org: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17702 ___ ___ Python-bugs-list mailing list