Łukasz Langa
f610bbdf74
gh-133346: Make theming support in _colorize extensible (GH-133347)
...
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-05-05 23:45:25 +02:00
sobolevn
641253cfac
gh-132385: Fix instance error suggestions trigger potential exceptions in `traceback` ( #132387 )
2025-05-02 15:52:59 +03:00
Pablo Galindo Salgado
32c4bbe834
gh-132449: Improve the algorithm to detect typos in keywords ( #132837 )
2025-04-23 14:45:18 +01:00
Pablo Galindo Salgado
bf3a0a1c0f
gh-132449: Improve syntax error messages for keywords with typos ( #132450 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-04-22 11:01:55 +02:00
Duprat
69cda31261
gh-132308: prevent `TracebackException` swallowing attributes of a falsey `Exception` or `ExceptionGroup` ( #132363 )
2025-04-19 09:49:18 +00:00
Pablo Galindo Salgado
a931a8b324
gh-117174: Add a new route in linecache to fetch interactive source code ( #117500 )
2025-03-10 21:54:05 +00:00
Irit Katriel
6c982aeb54
gh-130250: fix regression in traceback.print_last ( #130318 )
2025-02-19 21:44:35 +00:00
Ammar Askar
f9a7d41bac
gh-96092: Fix traceback.walk_stack(None) skipping too many frames ( #129330 )
...
As it says in its documentation, walk_stack was meant to just
follow `f.f_back` like other functions in the traceback module.
Instead it was previously doing `f.f_back.f_back` and then this
changed to `f_back.f_back.f_back.f_back' in Python 3.11 breaking
its behavior for external users.
This happened because the walk_stack function never really had
any good direct tests and its only consumer in the traceback module was
`extract_stack` which passed the result into `StackSummary.extract`.
As a generator, it was previously capturing the state of the stack
when it was first iterated over, rather than the stack when `walk_stack`
was called. Meaning when called inside the two method deep
`extract` and `extract_stack` calls, two `f_back`s were needed.
When 3.11 modified the sequence of calls in `extract`, two more
`f_back`s were needed to make the tests happy.
This changes the generator to capture the stack when `walk_stack` is
called, rather than when it is first iterated over. Since this is
technically a breaking change in behavior, there is a versionchanged
to the documentation. In practice, this is unlikely to break anyone,
you would have been needing to store the result of `walk_stack` and
expecting it to change.
2025-02-13 01:43:09 +00:00
sobolevn
a16ded10ad
gh-128894: Fix `TracebackException._format_syntax_error` on custom `SyntaxError` metadata ( #128946 )
2025-01-22 12:47:03 +00:00
Hugo van Kemenade
6f167d7134
gh-128595: Default to stdout isatty for colour detection instead of stderr ( #128498 )
...
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-20 12:52:42 +02:00
Tomas R.
8ba9f5bca9
gh-127347: Document `traceback.print_list` ( #127348 )
...
Previously, `traceback.print_list` didn't have a documentation entry and was not exposed in `traceback.__all__`. Now it has a documentation entry and is exposed in `__all__`.
2024-12-03 18:08:39 +02:00
Bogdan Romanyuk
51b012b2a8
gh-125593: Use colors to highlight error locations in tracebacks from exception group ( #125681 )
2024-10-27 01:57:10 +01:00
Bénédikt Tran
5cd50cb6eb
gh-122145: Handle an empty AST body when reporting tracebacks ( #122161 )
2024-09-18 18:42:33 +02:00
Pablo Galindo Salgado
48856ead6a
gh-123123: Fix display of syntax errors covering multiple lines ( #123131 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2024-08-19 15:09:03 +00:00
Alex Waygood
4b7eb321bc
gh-99180: Make `StackSummary.should_show_carets` private ( #119554 )
2024-05-25 17:08:32 +00:00
Pablo Galindo Salgado
a3e4fec873
gh-118893: Evaluate all statements in the new REPL separately ( #119318 )
...
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-21 23:16:56 +00:00
Serhiy Storchaka
0085c3ae8f
gh-116871: Improve name suggestions in tracebacks (GH-116930)
...
Only include underscored names in name suggestions for AttributeError and
ImportError if the original name was underscored.
2024-05-06 15:53:15 +03:00
Pablo Galindo Salgado
f27f8c790a
gh-111201: A new Python REPL (GH-111567)
...
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-05 21:32:23 +02:00
Hugo van Kemenade
3b3f8dea57
gh-117225: Move colorize functionality to own internal module ( #118283 )
2024-05-01 12:27:06 -06:00
Pablo Galindo Salgado
4a08a75cf4
gh-99180: Remove traceback anchors in return and assign statements that cover all the displayed range ( #112670 )
2024-05-01 14:42:10 +01:00
Pablo Galindo Salgado
345e1e04ec
gh-112730: Make the test suite resilient to color-activation environment variables ( #117672 )
2024-04-24 21:25:22 +01:00
Hugo van Kemenade
975081b11e
gh-117225: Add color to doctest output ( #117583 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-04-24 14:27:40 +03:00
Jérome Perrin
04fabe22dd
gh-113358: Fix rendering tracebacks with exceptions with a broken __getattr__ (GH-113359)
...
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-01-16 09:49:24 +00:00
Pablo Galindo Salgado
a03ec20bcd
gh-110721: Remove unused code from suggestions.c after moving PyErr_Display to use the traceback module ( #113712 )
2024-01-08 15:10:45 +00:00
Pablo Galindo Salgado
16448cab44
gh-112730: Use color to highlight error locations (gh-112732)
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-12-06 23:29:54 +01:00
William Wen
939fc6d6ea
gh-106922: Support multi-line error locations in traceback (attempt 2) ( #112097 )
2023-12-01 22:18:16 +00:00
Irit Katriel
2c68011780
gh-112332: Deprecate TracebackException.exc_type, add exc_type_str. ( #112333 )
2023-11-28 08:03:25 +00:00
Nikita Sobolev
aa732459c5
gh-111388: Add `show_group` parameter to `traceback.format_exception_only` ( #111390 )
2023-10-27 11:11:26 +01:00
Batuhan Taskaya
78e6d72e38
bpo-43950: handle wide unicode characters in tracebacks ( #28150 )
2023-10-26 07:05:29 +00:00
Pablo Galindo Salgado
90a1b2859f
gh-67224: Show source lines in tracebacks when using the -c option when running Python ( #111200 )
2023-10-26 15:17:28 +09:00
Nikita Sobolev
5e7727b052
gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring ( #111158 )
2023-10-21 15:30:14 +00:00
Pablo Galindo Salgado
e1d8c65e1d
gh-110805: Allow the repl to show source code and complete tracebacks ( #110775 )
2023-10-13 09:25:37 +00:00
Pablo Galindo Salgado
e7331365b4
gh-110721: Use the traceback module for PyErr_Display() and fallback to the C implementation ( #110702 )
2023-10-12 14:52:14 +00:00
Pablo Galindo Salgado
6275c67ea6
gh-106922: Fix error location for constructs with spaces and parentheses ( #108959 )
2023-09-08 17:18:35 +01:00
Irit Katriel
f4d8e10d0d
gh-105292: Add option to make traceback.TracebackException.format_exception_only recurse into exception groups ( #105294 )
...
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-06-06 11:26:18 +02:00
Jakub Kuczys
a4f72fa39a
gh-89412: Add missing attributes (added in 3.10) to traceback module docs ( #105046 )
2023-06-05 18:10:13 +02:00
Jakub Kuczys
39f6a0489f
GH-89455: Add missing attributes (added in 3.11) to traceback module docs ( #105044 )
2023-05-29 18:28:37 +00:00
Irit Katriel
a679c3d58d
gh-102799: replace sys.exc_info by sys.exception in inspect and traceback modules ( #104032 )
2023-05-01 18:19:47 +01:00
Carey Metcalfe
487f55d580
gh-103895: Improve how invalid `Exception.__notes__` are displayed ( #103897 )
2023-05-01 08:32:04 +01:00
Irit Katriel
e1e9bab006
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback ( #102779 )
2023-03-18 11:47:11 +00:00
Batuhan Taskaya
57be545959
gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)
...
Automerge-Triggered-By: GH:isidentical
2022-11-12 15:37:25 -08:00
Pablo Galindo Salgado
99e2e60cb2
gh-99139: Improve NameError error suggestion for instances ( #99140 )
2022-11-06 13:52:06 +00:00
Batuhan Taskaya
a41de32942
gh-98878: Use builtins from the bound frame when offering a suggestion ( #98880 )
2022-10-31 13:27:13 +00:00
Batuhan Taskaya
c0f2a5ef91
gh-98744: Prevent column-level decoding crashes on traceback module ( #98824 )
2022-10-29 13:28:20 +01:00
Pablo Galindo Salgado
7cfbb49fcd
gh-91058: Add error suggestions to 'import from' import errors ( #98305 )
2022-10-25 23:56:59 +01:00
Pablo Galindo Salgado
bb56dead33
gh-98254: Include stdlib module names in error messages for NameErrors ( #98255 )
2022-10-15 23:13:33 +01:00
Łukasz Langa
bbc7cd649a
gh-97008: Add a Python implementation of AttributeError and NameError suggestions ( #97022 )
...
Relevant tests moved from test_exceptions to test_traceback to be able to
compare both implementations.
Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
2022-10-04 15:31:16 -07:00
Simon-Martin Schröder
46fc584b00
gh-87822: Make traceback module robust to exceptions from repr() of local values (GH-94691)
2022-07-11 10:14:15 +01:00
John Belmonte
da717519ec
gh-93883: elide traceback indicators when possible ( #93994 )
...
* 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).
2022-07-11 07:40:53 +01:00
Irit Katriel
d4c4a76ed1
gh-89770: Implement PEP-678 - Exception notes (GH-31317)
2022-04-16 19:59:52 +01:00