This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年07月27日 12:10 by aliles, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| console.py | aliles, 2011年07月27日 12:10 | Demonstrate sys.excepthook behaviour from code.InteractiveConsole | ||
| startup.py | aliles, 2011年07月27日 12:56 | |||
| issue12643.diff | aliles, 2012年08月20日 08:11 | Add unit tests. Call sys.excepthook if overridden | review | |
| issue12643_2.diff | aliles, 2012年08月20日 12:32 | Updated patch to address feedback | review | |
| Messages (14) | |||
|---|---|---|---|
| msg141222 - (view) | Author: Aaron Iles (aliles) * | Date: 2011年07月27日 12:10 | |
code.InteractiveConsole doesn't match the CPython interactive interpreter with respect to allowing sys.excepthook to handle exceptions. Unlike the interactive interpreter, replacing sys.excepthook with an alternate function will not change exception handling behaviour from inside a code.InteractiveConole This affects downstream interpreters such as PyPy. https://bugs.pypy.org/issue811 |
|||
| msg141224 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年07月27日 12:29 | |
What do you suggest? |
|||
| msg141225 - (view) | Author: Aaron Iles (aliles) * | Date: 2011年07月27日 12:43 | |
OK. Not something I was expecting to be asked. But cool :D If it's not possible for InteractiveConsole to allow exceptions to propagate through sys.excepthook. (I assume they are being caught in a try: catch: block) check sys.excepthook for a custom exception handler and call present. As InteractiveConsole is supposed to "Closely emulate the behaviour of the interactive Python interpreter", any existing code that replies on it's current could be viewed as relying on a bug. I'd be happy to attempt a patch if it's worthwhile preparing one. |
|||
| msg141226 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年07月27日 12:48 | |
> If it's not possible for InteractiveConsole to allow exceptions > to propagate through sys.excepthook. Ok, I was not sure that I understood correctly. This change should be an option to not break existing code. |
|||
| msg141227 - (view) | Author: Aaron Iles (aliles) * | Date: 2011年07月27日 12:56 | |
Yes. I have code that behaves differently under CPython and PyPy because of this issue. Admittedly that code is somewhat evil. It's attached for reference, in particular the __HelpSyntax class. |
|||
| msg141367 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年07月29日 13:10 | |
If someone is setting sys.excepthook, they are not expecting it to be ignored, so I think there's no reason to preserve existing behaviour. On the other hand, it is easy to customize exception printout by subclassing InteractiveConsole and overriding the showtraceback() method. aliles, if you want to work on a patch, we have a developer's guide at http://docs.python.org/devguide/. |
|||
| msg141369 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年07月29日 13:11 | |
Another possibility yet is to add an "excepthook" argument to the InteractiveInterpreter / InteractiveConsole constructors. |
|||
| msg168635 - (view) | Author: Aaron Iles (aliles) * | Date: 2012年08月20日 08:11 | |
Submitted patch. Patch creates a new unit test suite with basic unit tests for InteractiveConsole. Enhances InteractiveConsole to call sys.excepthook instead of it's own handler if the user has overridden the excepthook. The unit tests use the new unittest.mock module and ExitStack class for contextlib. |
|||
| msg168652 - (view) | Author: Aaron Iles (aliles) * | Date: 2012年08月20日 12:32 | |
New patch to address comments provide by Nick Coghlan in person at PyCon-AU 2012. |
|||
| msg168656 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年08月20日 13:02 | |
New changeset a812de69b493 by Nick Coghlan in branch 'default': Issue #12643: Respect sys.excepthook in code.InteractiveConsole http://hg.python.org/cpython/rev/a812de69b493 |
|||
| msg168662 - (view) | Author: Andrew Svetlov (asvetlov) * (Python committer) | Date: 2012年08月20日 14:39 | |
Is it finished or not? Also looks like patch applied to 3.3 while issue marked for 2.7 and 3.2 also. |
|||
| msg168665 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2012年08月20日 14:50 | |
The patch also adds a test suite for the code module, in order to demonstrate that the issue is actually fixed. However, due to the interactive nature of the component, the new tests rely on unittest.mock. Backporting the test suite would mean eliminating that dependency (which is doable, but somewhat tedious). So we can either leave the issue open, indicating that a backport of the tests and change to 2.7 (and perhaps 3.2) is still acceptable, or else declare that we aren't going to worry about that and just leave this as something that is only supported properly in 3.3+ |
|||
| msg168666 - (view) | Author: Andrew Svetlov (asvetlov) * (Python committer) | Date: 2012年08月20日 14:58 | |
I'm ok with current status. Thanks for clarification. |
|||
| msg275909 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2016年09月12日 01:49 | |
3.2 is now dead and it's probably not worth to backport tests to 2.7 in 2016 :) Closing this as 'fixed'. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:20 | admin | set | github: 56852 |
| 2016年09月12日 01:49:27 | berker.peksag | set | status: open -> closed versions: + Python 3.3, - Python 2.7, Python 3.2 nosy: + berker.peksag messages: + msg275909 resolution: fixed stage: needs patch -> resolved |
| 2012年08月20日 14:58:29 | asvetlov | set | messages: + msg168666 |
| 2012年08月20日 14:50:02 | ncoghlan | set | messages:
+ msg168665 versions: - Python 3.3 |
| 2012年08月20日 14:39:05 | asvetlov | set | messages: + msg168662 |
| 2012年08月20日 13:02:43 | python-dev | set | nosy:
+ python-dev messages: + msg168656 |
| 2012年08月20日 12:32:31 | aliles | set | files:
+ issue12643_2.diff messages: + msg168652 |
| 2012年08月20日 10:36:53 | asvetlov | set | nosy:
+ asvetlov |
| 2012年08月20日 08:11:46 | aliles | set | files:
+ issue12643.diff nosy: + ncoghlan messages: + msg168635 keywords: + patch |
| 2012年03月28日 17:19:25 | flox | set | nosy:
+ flox |
| 2011年07月29日 13:11:44 | pitrou | set | messages: + msg141369 |
| 2011年07月29日 13:10:06 | pitrou | set | versions:
+ Python 3.3 nosy: + pitrou messages: + msg141367 stage: needs patch |
| 2011年07月27日 12:56:38 | aliles | set | files:
+ startup.py messages: + msg141227 |
| 2011年07月27日 12:48:15 | vstinner | set | messages: + msg141226 |
| 2011年07月27日 12:43:29 | aliles | set | messages: + msg141225 |
| 2011年07月27日 12:29:45 | vstinner | set | nosy:
+ vstinner messages: + msg141224 |
| 2011年07月27日 12:10:06 | aliles | create | |