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 2013年03月16日 21:17 by pjenvey, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| code.patch | Claudiu.Popa, 2013年08月20日 22:04 | review | ||
| issue17442.patch | Claudiu.Popa, 2014年03月11日 21:34 | Remove trailing whitespaces | review | |
| issue17442_1.patch | Claudiu.Popa, 2014年03月16日 18:20 | Added documentation note regarding this change. | review | |
| issue17442_2.patch | Claudiu.Popa, 2014年09月10日 12:44 | review | ||
| Messages (16) | |||
|---|---|---|---|
| msg184355 - (view) | Author: Philip Jenvey (pjenvey) * (Python committer) | Date: 2013年03月16日 21:17 | |
The code module claims to emulate Python's interactive interpreter but it fails to emulate displaying of the exception cause. It can utilize traceback._iter_chain to do this (see traceback.print_exception) |
|||
| msg187275 - (view) | Author: Philip Jenvey (pjenvey) * (Python committer) | Date: 2013年04月18日 18:00 | |
PyPy's fixed this here: https://bitbucket.org/pypy/pypy/commits/1341a432e134 The tests just need to be adapted to the stdlib test suite |
|||
| msg195719 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年08月20日 22:04 | |
Here's an updated patch for the stdlib, with adapted tests. |
|||
| msg198837 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年10月02日 13:21 | |
Could anyone review this patch, please? |
|||
| msg217103 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年04月23日 23:45 | |
I am on the fence as to whether this should be treated as a bug fix or enhancement. Claudiu's pydev post gives this as the current InteractiveInterpreter behavior. ------------------------------ >>> try: ... 1 / 0 ... except ZeroDivisionError as exc: ... raise IOError from exc ... Traceback (most recent call last): File "<console>", line 4, in <module> OSError ----------------------------------- This certainly is not an exact emulation (given below), but is it severe enough to be a bug, and moreover, would fixing it break code? Again from Claudiu's post: with the patch. --------------------------------- >>> try: ... 1 / 0 ... except ZeroDivisionError as exc: ... raise IOError from exc ... Traceback (most recent call last): File "<stdin>", line 2, in <module> ZeroDivisionError: division by zero The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<stdin>", line 4, in <module> OSError --------------------------------- I verified that this is exactly what 3.4.0 prints for interactive input, But... the Idle Shell also prints the above, plus it adds (or received from the user process) the offending code lines just as when the code is read from a file. ... File "<pyshell#0>", line 2, in <module> 1 / 0 ZeroDivisionError: division by zero ... File "<pyshell#0>", line 4, in <module> raise IOError from exc OSError Is there a reason the console interpreter cannot do the same? (Changing this would be a different issue, but one this would depend on.) |
|||
| msg217115 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年04月24日 04:58 | |
Python's interactive interpreter doesn't show the offending code lines too. And given the fact that code.InteractiveInterpreter tries to be an emulation of the default interpreter, first the change should be addressed directly there, I think. But I agree that it could be useful. |
|||
| msg221551 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年06月25日 14:36 | |
I would lean toward bug fix. I'm sure this was just overlooked when exception chaining was added, and as Claudiu says, the contract of code is to emulate the interactive interpreter, so not doing so in this instance looks like a bug to me. It is certainly conceivable that it could disrupt working programs, but I would think most such would be interactive programs that would benefit from the fix without breaking. Does anyone know of a counter example or can think of a use case for the code module that this change would be likely to break? (Note: if there is a use case that somehow parses the output, introducing blank lines and extra traceback clauses could easily be a breaking change...but is there such a use case?) |
|||
| msg221942 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年06月30日 06:08 | |
Well, for instance, my use cases with InteractiveInterpreter are for debugging or creating custom interpreters for various apps and in those cases the patch helps, by giving better debugging clues through the exception cause. I agree that this was overlooked when exception chaining was added. Also, idlelib's PyShell is based on InteractiveInterpreter, but in addition, it implements the exception chaining. |
|||
| msg221943 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年06月30日 06:12 | |
Also, solving this issue seems to be, partially, a prerequisite for issue14805. |
|||
| msg226683 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年09月10日 06:45 | |
If the patch doesn't need anything else, can it be committed? |
|||
| msg226690 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年09月10日 12:10 | |
Claudiu, did you see Jim Jewett's review on Rietveld? |
|||
| msg226691 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年09月10日 12:27 | |
Actually, no, it seems that I didn't receive any mail regarding them. I'll update the patch accordingly. |
|||
| msg226694 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年09月10日 12:44 | |
Here's the new version which fixes the comments from the review. |
|||
| msg227802 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年09月29日 15:26 | |
New changeset 2b212a8186e0 by R David Murray in branch 'default': #17442: Add chained traceback support to InteractiveInterpreter. https://hg.python.org/cpython/rev/2b212a8186e0 |
|||
| msg227803 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月29日 15:29 | |
After reconsidering Terry's idle example, it seems to me that the change could adversely impact existing code that already works around the lack of chained tracebacks, even as idle does. So I committed this to 3.5 only as an enhancement. Thanks Claudiu. As an aside, isn't it a (pre-existing) bug that if an excepthook exists, it gets passed None for the traceback? |
|||
| msg227812 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2014年09月29日 17:45 | |
Indeed, it's a preexisting bug. I'll try to come up with a patch shortly. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:42 | admin | set | github: 61644 |
| 2014年09月29日 17:45:51 | Claudiu.Popa | set | messages: + msg227812 |
| 2014年09月29日 15:29:43 | r.david.murray | set | status: open -> closed versions: - Python 3.4 type: behavior -> enhancement messages: + msg227803 resolution: fixed stage: commit review -> resolved |
| 2014年09月29日 15:26:05 | python-dev | set | nosy:
+ python-dev messages: + msg227802 |
| 2014年09月10日 12:44:51 | Claudiu.Popa | set | files:
+ issue17442_2.patch messages: + msg226694 |
| 2014年09月10日 12:27:13 | Claudiu.Popa | set | messages: + msg226691 |
| 2014年09月10日 12:10:29 | berker.peksag | set | nosy:
+ berker.peksag messages: + msg226690 |
| 2014年09月10日 06:46:00 | Claudiu.Popa | set | messages:
+ msg226683 stage: patch review -> commit review |
| 2014年06月30日 06:12:11 | Claudiu.Popa | set | messages: + msg221943 |
| 2014年06月30日 06:08:16 | Claudiu.Popa | set | messages: + msg221942 |
| 2014年06月25日 14:36:35 | r.david.murray | set | messages: + msg221551 |
| 2014年06月25日 13:20:29 | Claudiu.Popa | set | nosy:
+ r.david.murray |
| 2014年04月24日 04:58:41 | Claudiu.Popa | set | messages: + msg217115 |
| 2014年04月23日 23:45:12 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg217103 |
| 2014年03月19日 20:01:56 | zach.ware | set | versions: + Python 3.5, - Python 3.3 |
| 2014年03月16日 18:20:49 | Claudiu.Popa | set | files: + issue17442_1.patch |
| 2014年03月11日 21:34:24 | Claudiu.Popa | set | files: + issue17442.patch |
| 2013年10月03日 19:34:00 | pitrou | set | nosy:
+ georg.brandl, serhiy.storchaka |
| 2013年10月02日 21:59:56 | pitrou | set | nosy:
+ pitrou stage: patch review versions: - Python 3.2 |
| 2013年10月02日 13:21:26 | Claudiu.Popa | set | messages: + msg198837 |
| 2013年08月20日 22:04:11 | Claudiu.Popa | set | files:
+ code.patch nosy: + Claudiu.Popa messages: + msg195719 keywords: + patch |
| 2013年04月18日 18:00:17 | pjenvey | set | messages: + msg187275 |
| 2013年03月16日 21:17:44 | pjenvey | create | |