[issue6210] Exception Chaining missing method for suppressing context

2012-02-26 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset b299c4f31ff2 by Nick Coghlan in branch 'default': Close issue #6210: Implement PEP 409 http://hg.python.org/cpython/rev/b299c4f31ff2 -- nosy: +python-dev ___ Python

[issue6210] Exception Chaining missing method for suppressing context

2012-02-26 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___

[issue6210] Exception Chaining missing method for suppressing context

2012-02-26 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: Thanks, I can’t wait to use that in my code! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___

[issue6210] Exception Chaining missing method for suppressing context

2012-02-15 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Remaining problems: - default sys.excepthook implementation currently does the wrong thing Unable to duplicate on my system (Win XP SP3) - needs a test for the pythonrun display logic (test_cmd_line_script would be the appropriate place)

[issue6210] Exception Chaining missing method for suppressing context

2012-02-07 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- assignee: - ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___ Python-bugs-list

[issue6210] Exception Chaining missing method for suppressing context

2012-02-07 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: I started work on integrating this into 3.3 this evening, but ran into too many issues to finish it. Problems found and fixed: - traceback.py displayed the wrong exception (test added and impl fixed) Additional changes: - eliminated duplicate

[issue6210] Exception Chaining missing method for suppressing context

2012-02-07 Thread Raghuram Devarakonda
Changes by Raghuram Devarakonda draghu...@gmail.com: -- nosy: -draghuram ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2012-02-03 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Because Ellipsis is now the default value for __cause__, 'raise ... from Ellipsis' is treated the same as 'raise ...' Not exactly true -- if ... is a new exception then they are the same; if ... is a caught exception that is being reraised,

[issue6210] Exception Chaining missing method for suppressing context

2012-02-03 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: I just noticed that no one is assigned to this issue -- anybody on the nosy list able to review? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210

[issue6210] Exception Chaining missing method for suppressing context

2012-02-02 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Latest version of PEP is on python-dev; here is the latest patch. Summary: For __cause__ we are replacing the old special value of None with Ellipsis: Ellipsis means check __context__ for an exception to display; None means ignore

[issue6210] Exception Chaining missing method for suppressing context

2012-02-02 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: PEP 409 has been accepted. :) Attached is the latest patch implementing it, with the (hopefully ;) final changes. Because Ellipsis is now the default value for __cause__, 'raise ... from Ellipsis' is treated the same as 'raise ...'

[issue6210] Exception Chaining missing method for suppressing context

2012-01-31 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Attached patch now includes doc changes. -- Added file: http://bugs.python.org/file24386/raise_from_none_v4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210

[issue6210] Exception Chaining missing method for suppressing context

2012-01-31 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Okay, *all* the documentation updates this time. Thanks, Nick! -- Added file: http://bugs.python.org/file24387/raise_from_none_v5.diff ___ Python tracker rep...@bugs.python.org

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: Ah, nice idea of bringing the boolean constants into the mix so we don't need to invent a new sentinel value. However, to preserve the current behaviour that raise X from Y is essentially just syntactic sugar for: _var = X; _var.__cause__ =

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Current semantics (before patch): cause is not None -- cause is set, display it instead of context cause is None -- no cause, try to display context context is not None -- no context context is None -- context set, display it (unless cause

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: Hmm, so from None sets cause to True, while all other from X sets cause to X. That does not sound like a good idea to me. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Patrick Westerhoff
Patrick Westerhoff patrickwesterh...@gmail.com added the comment: I have to agree with Georg on that. I think it would make more sense to introduce some internal flag/variable that keeps track of if the cause was explicitely set. So if cause was set (i.e. `from X` syntax is used), then always

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Patrick: The value in this enhancement is in not displaying the chained exception. I do not see any value in throwing it away completely. If you don't care about __context__ you can safely ignore it. On the other hand, if it is completely

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Not sure I have traceback._iter_chain() patched correctly, but all the tests pass. Here's the latest code. -- Added file: http://bugs.python.org/file24362/raise_from_none_v3.diff ___ Python tracker

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Steven D'Aprano
Steven D'Aprano steve+pyt...@pearwood.info added the comment: Patrick Westerhoff wrote: Patrick Westerhoff patrickwesterh...@gmail.com added the comment: I have to agree with Georg on that. I think it would make more sense to introduce some internal flag/variable that keeps track of if the

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: This was discussed a little more in the python-dev thread for PEP 409, but both Guido and I have been burned in the past by badly written libraries that replaced detailed exceptions that explained *exactly* what was going wrong with bland,

[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Patrick Westerhoff
Patrick Westerhoff patrickwesterh...@gmail.com added the comment: Oh, where did that PEP come from? ^^ Also thanks for hinting at python-dev, didn’t realize that there was a discussion going on about this! -- ___ Python tracker

[issue6210] Exception Chaining missing method for suppressing context

2012-01-28 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: It looks like agreement is forming around the raise ... from None method. It has been mentioned more than once that having the context saved on the exception would be a Good Thing, and for further debugging (or logging or what-have-you)

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Okay, here is a patch implementing the 'raise ... from None' method. All critiques appreciated (especially if they include links to learn from!). -- keywords: +patch Added file: http://bugs.python.org/file24332/raise_from_none.diff

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: I went with raise ... from None instead of raise as ... because there seemed to me more support for 'from None' on python-dev, possible confusion with 'raise as', and 'from None' follows the existing systax of raise

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: 1. Any syntax change requires a PEP (and, IMO, any such PEP for this issue should get rejected: I don't consider this an important enough feature to deserve dedicated syntax. Others disagree, which is one of the reasons why a PEP is needed.

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: 1. Any syntax change requires a PEP (and, IMO, any such PEP for this issue should get rejected: I don't consider this an important enough feature to deserve dedicated syntax. Others disagree, which is one of the reasons why a PEP is

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Nick Coghlan wrote: 1. Any syntax change requires a PEP PEP is on python-dev. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Steven D'Aprano
Steven D'Aprano steve+pyt...@pearwood.info added the comment: Nick Coghlan wrote: Nick Coghlan ncogh...@gmail.com added the comment: 1. Any syntax change requires a PEP (and, IMO, any such PEP for this issue should get rejected: I don't consider this an important enough feature to deserve

[issue6210] Exception Chaining missing method for suppressing context

2012-01-26 Thread Steven D'Aprano
Steven D'Aprano steve+pyt...@pearwood.info added the comment: [...] My comment has been overtaken by additional comments by Nick on the Python-Dev list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210

[issue6210] Exception Chaining missing method for suppressing context

2012-01-23 Thread Catalin Iacob
Changes by Catalin Iacob iacobcata...@gmail.com: -- nosy: +catalin.iacob ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2012-01-12 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Okay, I like Matthew Barnett's idea of except SomeError [as e]: raise as SomeOtherError('...') This would require a change to the grammer as well, yes? From: raise_stmt: 'raise' [test ['from' test]] to raise_stmt:

[issue6210] Exception Chaining missing method for suppressing context

2012-01-12 Thread Patrick Westerhoff
Patrick Westerhoff patrickwesterh...@gmail.com added the comment: Yeah, I would really like that solution, especially as it separates from the `from X` syntax that sets the exception’s cause. Also I would prefer a syntax solution over a class method simply because the exception context is

[issue6210] Exception Chaining missing method for suppressing context

2011-10-22 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: I like the class method idea, but not the no_context name. Would without_context be too long? I don’t dislike raise MyError from None, but a method will be more easy to search and will help people reading code and discovering this unknown

[issue6210] Exception Chaining missing method for suppressing context

2011-10-13 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___ Python-bugs-list

[issue6210] Exception Chaining missing method for suppressing context

2011-03-16 Thread Armin Ronacher
Changes by Armin Ronacher armin.ronac...@active-4.com: -- nosy: +aronacher ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2011-03-16 Thread Matthew Barnett
Matthew Barnett pyt...@mrabarnett.plus.com added the comment: I've been looking through the list of current keywords and the best syntax I could come up with for suppressing the context is: try: x / y except ZeroDivisionError as e: raise as Exception( 'Invalid value for

[issue6210] Exception Chaining missing method for suppressing context

2010-12-31 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Le vendredi 31 décembre 2010 à 00:07 +, Patrick W. a écrit : Patrick W. p...@borntolaugh.de added the comment: Antoine Pitrou (pitrou) at 2010-12-30 18:32 (UTC) We are talking about context, not cause. Yes, but - as said before -

[issue6210] Exception Chaining missing method for suppressing context

2010-12-31 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: raise AttributeError from None makes sense to me, and in a nice, short example like that I prefer it. In real code, however, I think raise AttributeError.no_context(Field %s is not in table % attr) is going to be easier for the human to

[issue6210] Exception Chaining missing method for suppressing context

2010-12-30 Thread Patrick W.
Patrick W. p...@borntolaugh.de added the comment: Nick Coghlan (ncoghlan) at 2010-12-29 08:46 (UTC): No, the context must always be included unless explicitly suppressed. Then there should be some actually working way to suppress it, right? I think the standard behaviour that automatically

[issue6210] Exception Chaining missing method for suppressing context

2010-12-30 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: using `None` as the cause of an exception would be the best solution in my opinion: +1 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210

[issue6210] Exception Chaining missing method for suppressing context

2010-12-30 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: using `None` as the cause of an exception would be the best solution in my opinion: +1 We are talking about context, not cause. -- ___ Python tracker rep...@bugs.python.org

[issue6210] Exception Chaining missing method for suppressing context

2010-12-30 Thread Patrick W.
Patrick W. p...@borntolaugh.de added the comment: Antoine Pitrou (pitrou) at 2010-12-30 18:32 (UTC) We are talking about context, not cause. Yes, but - as said before - obviously the cause takes a higher precedence than context (otherwise it wouldn't show a context message when you

[issue6210] Exception Chaining missing method for suppressing context

2010-12-29 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: No, the context must always be included unless explicitly suppressed. The interpreter can't reliably tell the difference between a raise statement in the current exception handler and one buried somewhere inside a nested function call. The

[issue6210] Exception Chaining missing method for suppressing context

2010-12-29 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: For can't tell in my previous message, read we aren't going to impose the requirement to be able to tell if an exception is being raised directly in the current exception handler as a feature of conforming Python implementations. We probably

[issue6210] Exception Chaining missing method for suppressing context

2010-12-29 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Le mercredi 29 décembre 2010 à 01:15 +, Ethan Furman a écrit : Ethan Furman et...@stoneleaf.us added the comment: I'm talking about the exception raised from the except block. So was I -- why should this: try: x = y / z except

[issue6210] Exception Chaining missing method for suppressing context

2010-12-29 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: I said the *except* block, not the *try* block ;) Ah. So you did. Okay, if I'm understanding correctly, the scenario you are talking about involves the code in the except block calling some other function, and that other function is

[issue6210] Exception Chaining missing method for suppressing context

2010-12-29 Thread Ethan Furman
Changes by Ethan Furman et...@stoneleaf.us: -- versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I'm not sure how that's going to help as I don't want my library code to be responsible for printing out exceptions, I just want them to print reasonably -- and it seems very unreasonable to have the exception I'm converting /from/ show up in

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: Besides, if you are writing library code (as opposed to application code), you shouldn't care at all how tracebacks are displayed, should you? I care when it lies: During handling of the above exception, another exception occurred: This is

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: During handling of the above exception, another exception occurred: This is a blatant falsehood -- another exception did not occur, a different exception was raised. This doesn't make any difference in any other context, so why would it

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: During handling of the above exception, another exception occurred: This is a blatant falsehood -- another exception did not occur, a different exception was raised. This doesn't make any difference in any other context, so why would it

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: and, finally, if all I have is except ValueError as exc: raise AttributeError(blah) I just get the normal, previous context free, traceback. And what if the exception is raised from a subroutine? --

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: And what if the exception is raised from a subroutine? Well, if I have it surrounded by a try/except block, presumably I'm aware that an exception could be raised. ;) And if I'm aware that an exception could be raised, it may also be

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: And what if the exception is raised from a subroutine? Well, if I have it surrounded by a try/except block, presumably I'm aware that an exception could be raised. ;) I'm talking about the exception raised from the except block.

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: I'm talking about the exception raised from the except block. So was I -- why should this: try: x = y / z except ZeroDivisionError as exc: raise InvalidInput() be different from this: try: x = divide_and_conquer(y, z) except

[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___ Python-bugs-list

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Ethan Furman
Changes by Ethan Furman et...@stoneleaf.us: -- nosy: +stoneleaf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___ Python-bugs-list

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: I like MRAB's suggestion best: MRAB wrote: Suggestion: an explicit 'raise' in the exception handler excludes the context, but if you want to include it then 'raise with'. For example: # Exclude the context try: command_dict[command]()

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I agree with the OP that we need a way to either suppress chaining or have it turned-off by default. A person writing an exception handler should have control over what the user sees. -- nosy: +rhettinger

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Matthew Barnett
Changes by Matthew Barnett pyt...@mrabarnett.plus.com: -- nosy: +mrabarnett ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: A person writing an exception handler should have control over what the user sees. There is already support for this in the traceback module (see the chain parameter to various funcs). -- ___ Python

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Ethan Furman
Ethan Furman et...@stoneleaf.us added the comment: There is already support for this in the traceback module (see the chain parameter to various funcs). I'm not sure how that's going to help as I don't want my library code to be responsible for printing out exceptions, I just want them to

[issue6210] Exception Chaining missing method for suppressing context

2010-12-27 Thread Matthew Barnett
Matthew Barnett pyt...@mrabarnett.plus.com added the comment: Regarding syntax, I'm undecided between: raise with new_exception and: raise new_exception with caught_exception I think that the second form is clearer: try: ... exception SomeException as ex:

[issue6210] Exception Chaining missing method for suppressing context

2010-12-04 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- assignee: - pitrou nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2010-12-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: It is not possible to do this using a method, since raise exc will add a context anyway. So, if this is desired, it needs some new syntax and should be discussed on python-ideas. (I don't think this is very important personally. Tracebacks are

[issue6210] Exception Chaining missing method for suppressing context

2010-12-04 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: To get back to my original objection, it shouldn't be that difficult to differentiate between __context__ never set and __context__ explicitly suppressed. (e.g. using a property that sets an internal flag when set from Python code or via

[issue6210] Exception Chaining missing method for suppressing context

2010-12-03 Thread Steven D'Aprano
Steven D'Aprano steve+pyt...@pearwood.info added the comment: It seems to me that an explicit raise inside an except block should *not* chain exceptions by default. The rationale for chaining exceptions is to detect bugs in the exception handler: try: something except SomeError: y =

[issue6210] Exception Chaining missing method for suppressing context

2010-08-03 Thread Raghuram Devarakonda
Changes by Raghuram Devarakonda draghu...@gmail.com: -- nosy: +draghuram ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___

[issue6210] Exception Chaining missing method for suppressing context

2009-06-12 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: The current behaviour also doesn't match the spec in PEP 3134, which states the __context__ attribute will only be set by the VM if it hasn't already been set. This is not currently the case, as setting __context__ does not keep the VM from

[issue6210] Exception Chaining missing method for suppressing context

2009-06-05 Thread Patrick W.
New submission from Patrick W. p...@borntolaugh.de: I'm currently writing a library that executes predefined http requests to a specified server. In case there is for example a HTTP Error, I want to raise a user-defined exception that contains additional information about when the error actually

[issue6210] Exception Chaining missing method for suppressing context

2009-06-05 Thread Benjamin Peterson
Changes by Benjamin Peterson benja...@python.org: -- versions: +Python 3.2 -Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6210 ___ ___