summaryrefslogtreecommitdiffstats
path: root/Lib/traceback.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-87822: Make traceback module robust to exceptions from repr() of local ↵Simon-Martin Schröder2022-07-111-1/+2
| | | | values (GH-94691)
* gh-93883: elide traceback indicators when possible (#93994)John Belmonte2022-07-111-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gh-93883: elide traceback indicators when possible Elide traceback column indicators when the entire line of the frame is implicated. This reduces traceback length and draws even more attention to the remaining (very relevant) indicators. Example: ``` Traceback (most recent call last): File "query.py", line 99, in <module> bar() File "query.py", line 66, in bar foo() File "query.py", line 37, in foo magic_arithmetic('foo') File "query.py", line 18, in magic_arithmetic return add_counts(x) / 25 ^^^^^^^^^^^^^ File "query.py", line 24, in add_counts return 25 + query_user(user1) + query_user(user2) ^^^^^^^^^^^^^^^^^ File "query.py", line 32, in query_user return 1 + query_count(db, response['a']['b']['c']['user'], retry=True) ~~~~~~~~~~~~~~~~~~^^^^^ TypeError: 'NoneType' object is not subscriptable ``` Rather than going out of our way to provide indicator coverage in every traceback test suite, the indicator test suite should be responible for sufficient coverage (e.g. by adding a basic exception group test to ensure that margin strings are covered).
* gh-89770: Implement PEP-678 - Exception notes (GH-31317)Irit Katriel2022-04-161-10/+14
|
* bpo-45615: Add missing test for printing traceback for non-exception. Fix ↵Irit Katriel2022-01-021-1/+5
| | | | traceback.py (GH-30091)
* bpo-45607: Make it possible to enrich exception displays via setting their ↵Irit Katriel2021-12-031-0/+4
| | | | __note__ field (GH-29880)
* bpo-45614: Fix traceback display for exceptions with invalid module name ↵Irit Katriel2021-11-271-0/+2
| | | | (GH-29726)
* bpo-45292: [PEP 654] Update traceback display code to work with exception ↵Irit Katriel2021-11-051-13/+128
| | | | groups (GH-29207)
* bpo-45249: Fix caret location when end_offset is set to 0 (GH-28855)Pablo Galindo Salgado2021-10-161-1/+1
|
* bpo-45249: Ensure the traceback module prints correctly syntax errors with ↵Pablo Galindo Salgado2021-09-271-6/+21
| | | | ranges (GH-28575)
* bpo-41031: Match C and Python code formatting of unprintable exceptions and ↵Irit Katriel2021-09-051-1/+1
| | | | exceptions in the __main__ module. (GH-28139)
* bpo-45075: distinguish between frame and FrameSummary in traceback mo… ↵Irit Katriel2021-09-031-29/+33
| | | | (GH-28112)
* bpo-31299: make it possible to filter out frames from tracebacks (GH-28067)Irit Katriel2021-08-311-0/+3
|
* bpo-43950: support some multi-line expressions for PEP 657 (GH-27339)Batuhan Taskaya2021-07-251-8/+10
| | | | | | | | | | | | | | | | | | | | | This is basically something that I noticed up while fixing test runs for another issue. It is really common to have multiline calls, and when they fail the display is kind of weird since we omit the annotations. E.g; ``` $ ./python t.py Traceback (most recent call last): File "/home/isidentical/cpython/cpython/t.py", line 11, in <module> frame_1() ^^^^^^^^^ File "/home/isidentical/cpython/cpython/t.py", line 5, in frame_1 frame_2( File "/home/isidentical/cpython/cpython/t.py", line 2, in frame_2 return a / 0 / b / c ~~^~~ ZeroDivisionError: division by zero ``` This patch basically adds support for annotating the rest of the line, if the instruction covers multiple lines (start_line != end_line). Automerge-Triggered-By: GH:isidentical
* bpo-43950: support long lines in traceback.py (GH-27336)Batuhan Taskaya2021-07-241-1/+5
|
* bpo-44569: Decouple frame formatting in traceback.py (GH-27038)Ammar Askar2021-07-161-34/+44
|
* bpo-43950: make BinOp specializations more reliable (GH-27126)Batuhan Taskaya2021-07-151-1/+1
|
* bpo-43950: Specialize tracebacks for subscripts/binary ops (GH-27037)Batuhan Taskaya2021-07-121-1/+59
| | | | Co-authored-by: Ammar Askar <ammar@ammaraskar.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-44446: support lineno being None in traceback.FrameSummary (GH-26781)Filipe Laíns2021-07-081-0/+2
| | | | | | As of 088a15c49d99ecb4c3bef93f8f40dd513c6cae3b, lineno is None instead of -1 if there is no line number. Signed-off-by: Filipe Laíns <lains@riseup.net>
* bpo-43950: Print columns in tracebacks (PEP 657) (GH-26958)Ammar Askar2021-07-041-10/+79
| | | | | | | | The traceback.c and traceback.py mechanisms now utilize the newly added code.co_positions and PyCode_Addr2Location to print carets on the specific expressions involved in a traceback. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
* bpo-43024: improve signature (in help, etc) for functions taking sent… ↵Irit Katriel2021-06-171-1/+4
| | | | | (GH-24331) …inel defaults
* bpo-33809: add the TracebackException.print() method (GH-24231)Irit Katriel2021-05-221-4/+8
|
* bpo-43146: fix None-handling in single-arg traceback.print_exception(None) ↵Irit Katriel2021-02-231-1/+4
| | | | | (GH-24629) (The previous commit fixed print_exception(None, None, None).)
* bpo-43146: fix regression in traceback.print_exception(None) (GH-24463)Irit Katriel2021-02-231-1/+3
|
* bpo-42877: add the 'compact' param to TracebackException's __init__ (#24179)Irit Katriel2021-01-151-9/+16
| | | Use it to reduce the time and memory taken up by several of traceback's module-level functions.
* bpo-42848: remove recursion from TracebackException (GH-24158)Irit Katriel2021-01-121-46/+69
|
* bpo-34463: Make python tracebacks identical to C tracebacks for SyntaxErrors ↵Irit Katriel2020-12-221-5/+9
| | | | without a lineno (GH-23427)
* bpo-42482: remove reference to exc_traceback from TracebackException (GH-23531)Irit Katriel2020-12-011-3/+2
|
* bpo-26389: Allow passing an exception object in the traceback module (GH-22610)Zackery Spytz2020-11-051-13/+23
| | | | | | The format_exception(), format_exception_only(), and print_exception() functions can now take an exception object as a positional-only argument. Co-Authored-By: Matthias Bussonnier <bussonniermatthias@gmail.com>
* bpo-40612: Fix SyntaxError edge cases in traceback formatting (GH-20072)Guido van Rossum2020-05-151-11/+18
| | | | | | | | | | | | | This fixes both the traceback.py module and the C code for formatting syntax errors (in Python/pythonrun.c). They now both consistently do the following: - Suppress caret if it points left of text - Allow caret pointing just past end of line - If caret points past end of line, clip to *just* past end of line The syntax error formatting code in traceback.py was mostly rewritten; small, subtle changes were applied to the C code in pythonrun.c. There's still a difference when the text contains embedded newlines. Neither handles these very well, and I don't think the case occurs in practice. Automerge-Triggered-By: @gvanrossum
* Fix typo in Lib/tracepack.py (GH-19605)Galden2020-04-201-1/+1
| | | Typo fix: "emites" -> "emit".
* bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)Serhiy Storchaka2019-08-081-1/+3
| | | | They now return NotImplemented for unsupported type of the other operand.
* bpo-26502: Implement FrameSummary.__len__() (GH-8632)Berker Peksag2018-09-101-0/+3
|
* bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)Benjamin Peterson2018-09-101-10/+19
| | | | | | | | The recursive frame pruning code always undercounted the number of elided frames by one. That is, in the "[Previous line repeated N more times]" message, N would always be one too few. Near the recursive pruning cutoff, one frame could be silently dropped. That situation is demonstrated in the OP of the bug report. The fix is to start the identical frame counter at 1.
* bpo-27910: Update documentation of traceback module (GH-6116)torsava2018-08-021-13/+16
| | | | | | | | | | In the documentation for the traceback module, the definitions of functions extract_tb(), format_list() and classmethod StackSummary.from_list() mention the old style 4-tuples that these functions used to return or accept. Since Python 3.5, however, they return or accept a FrameSummary object instead of a 4-tuple, or a StackSummary object instead of a list of 4-tuples. Co-Authored-By: Berker Peksag <berker.peksag@gmail.com>
* bpo-28603: Fix formatting tracebacks for unhashable exceptions (#4014)Zane Bitter2017-10-171-3/+3
|
* bpo-30296 Remove unnecessary tuples, lists, sets, and dicts (#1489)Jon Dufresne2017-05-181-2/+1
| | | | | | | | * Replaced list(<generator expression>) with list comprehension * Replaced dict(<generator expression>) with dict comprehension * Replaced set(<list literal>) with set literal * Replaced builtin func(<list comprehension>) with func(<generator expression>) when supported (e.g. any(), all(), tuple(), min(), & max())
* Issue #27348: Merge exception formatting fix from 3.5 into 3.6Martin Panter2016-09-221-1/+1
|\
| * Issue #27348: Restore “Exception: None” formatting in traceback moduleMartin Panter2016-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression caused by revision 73afda5a4e4c. Also reverts the decimal test workaround added in revision 5f3dd0a2b1ab. Remove test_without_exception(). According to revision ecaafc32c500, this was added in Python 2 so that print_exc() would output “None” when called with no exception set. However print_exc() never worked like this in Python 3, and the use case is not documented. Restore TracebackCases class name (instead of SyntaxTracebackCases), because the class also tests other exceptions.
* | Issue 27948: Allow backslashes in the literal string portion of f-strings, ↵Eric V. Smith2016-09-101-2/+2
| | | | | | | | but not in the expressions. Also, require expressions to begin and end with literal curly braces.
* | Issue 27921: Remove backslash from another f-string. I'll revert this change ↵Eric V. Smith2016-09-031-2/+2
| | | | | | | | before beta 2. I also need to look in to why test_tools/test_unparse fails with the files that are now being skipped.
* | Closes issue 27921: Disallow backslashes anywhere in f-strings. This is a ↵Eric V. Smith2016-09-031-2/+2
| | | | | | | | temporary restriction. In 3.6 beta 2, the plan is to again allow backslashes in the string parts of f-strings, but disallow them in the expression parts.
* | Issue #26823: Abbreviate recursive tracebacksNick Coghlan2016-08-151-0/+23
| | | | | | | | | | | | | | | | Large sections of repeated lines in tracebacks are now abbreviated as "[Previous line repeated {count} more times]" by both the traceback module and the builtin traceback rendering. Patch by Emanuel Barry.
* | Issue #27076: Merge spelling from 3.5Martin Panter2016-05-261-5/+5
|\ \ | |/
| * Issue #27076: Doc, comment and tests spelling fixesMartin Panter2016-05-261-5/+5
| | | | | | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* | Issue #25111: Fixed comparison of traceback.FrameSummary.Serhiy Storchaka2015-09-291-4/+8
|\ \ | |/
| * Issue #25111: Fixed comparison of traceback.FrameSummary.Serhiy Storchaka2015-09-291-4/+8
| |
* | Issue #25108: Omitted internal frames in traceback functions print_stack(),Serhiy Storchaka2015-09-181-0/+6
|\ \ | |/ | | | | format_stack(), and extract_stack() called without arguments.
| * Issue #25108: Omitted internal frames in traceback functions print_stack(),Serhiy Storchaka2015-09-181-0/+6
| | | | | | | | format_stack(), and extract_stack() called without arguments.
* | Issue #24710: Use cls in TracebackException.from_exception.Robert Collins2015-07-251-3/+2
|/ | | | Minor cleanup patch from Berker Peksag.
* Issue #24695: Fix a regression in traceback.print_exception()Berker Peksag2015-07-241-1/+3
| | | | | If exc_traceback is None we shouldn't print a traceback header like described in the documentation.