Commit Graph

128 Commits

Author SHA1 Message Date
Irit Katriel a82baed0e9
bpo-45615: Add missing test for printing traceback for non-exception. Fix traceback.py (GH-30091) 2022-01-02 09:34:03 +00:00
Carl Friedrich Bolz-Tereick b593bdc780
bpo-37971: fix the position of decorator application (GH-30027)
The line numbers of actually calling the decorator functions of
functions and classes was wrong (as opposed to loading them, were they
have been correct previously too).

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-12-11 00:45:02 +01:00
Irit Katriel 5bb7ef2768
bpo-45607: Make it possible to enrich exception displays via setting their __note__ field (GH-29880) 2021-12-03 22:01:15 +00:00
Irit Katriel 4dfae6f38e
bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726) 2021-11-27 22:00:10 +00:00
Irit Katriel 3509b26c91
bpo-45292: [PEP 654] Update traceback display code to work with exception groups (GH-29207) 2021-11-05 09:39:18 +00:00
Pablo Galindo Salgado fe0d9e22a5
bpo-45249: Fix caret location when end_offset is set to 0 (GH-28855) 2021-10-16 10:27:43 -07:00
Pablo Galindo Salgado 20f439b6b9
bpo-45249: Ensure the traceback module prints correctly syntax errors with ranges (GH-28575) 2021-09-27 21:59:06 +01:00
Irit Katriel 9e31b3952f
bpo-41031: Match C and Python code formatting of unprintable exceptions and exceptions in the __main__ module. (GH-28139) 2021-09-05 18:54:13 +03:00
Irit Katriel 0b58e863df
bpo-45075: distinguish between frame and FrameSummary in traceback mo… (GH-28112) 2021-09-03 22:39:23 +01:00
Irit Katriel b4b6342848
bpo-45083: Include the exception class qualname when formatting an exception (GH-28119)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-09-03 09:30:17 +02:00
Irit Katriel 863154c929
bpo-31299: make it possible to filter out frames from tracebacks (GH-28067) 2021-08-31 21:42:08 +01:00
Batuhan Taskaya 3e235e0447
bpo-43950: support some multi-line expressions for PEP 657 (GH-27339)
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
2021-07-25 15:01:44 -07:00
Batuhan Taskaya 4f5980a4f5
bpo-43950: support long lines in traceback.py (GH-27336) 2021-07-24 20:50:39 +03:00
Batuhan Taskaya c8362314cc
bpo-43950: ensure source_line is present when specialising the traceback (GH-27313) 2021-07-24 13:50:19 +01:00
Ammar Askar 8ce3008585
bpo-44569: Decouple frame formatting in traceback.py (GH-27038) 2021-07-16 13:21:16 +01:00
Batuhan Taskaya 919ad53751
bpo-43950: make BinOp specializations more reliable (GH-27126) 2021-07-16 00:38:11 +01:00
Batuhan Taskaya 1890dd235f
bpo-43950: Specialize tracebacks for subscripts/binary ops (GH-27037)
Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-07-12 20:32:33 +01:00
Filipe Laíns 91a8f8c16c
bpo-44446: support lineno being None in traceback.FrameSummary (GH-26781)
As of 088a15c49d, lineno is None instead
of -1 if there is no line number.

Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-07-08 17:28:01 +01:00
Ammar Askar 052930f241
Remove __cleanenv from PEP-657 tests (GH-27060) 2021-07-07 22:47:50 +01:00
Ammar Askar 4823d9a512
bpo-43950: Add option to opt-out of PEP-657 (GH-27023)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2021-07-07 20:07:12 +01:00
Ammar Askar 5644c7b3ff
bpo-43950: Print columns in tracebacks (PEP 657) (GH-26958)
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>
2021-07-05 00:14:33 +01:00
Irit Katriel f73377d57c
bpo-43024: improve signature (in help, etc) for functions taking sent… (GH-24331)
…inel defaults
2021-06-17 09:14:30 -07:00
Irit Katriel 220dd80a26
bpo-33809: add the TracebackException.print() method (GH-24231) 2021-05-22 17:39:33 +01:00
Irit Katriel b798ab0693
bpo-43146: fix None-handling in single-arg traceback.print_exception(None) (GH-24629)
(The previous commit fixed print_exception(None, None, None).)
2021-02-23 09:43:04 -08:00
Irit Katriel 26f18b8540
bpo-43146: fix regression in traceback.print_exception(None) (GH-24463) 2021-02-23 06:58:47 -08:00
Irit Katriel 4c94d74152
bpo-42877: add the 'compact' param to TracebackException's __init__ (#24179)
Use it to reduce the time and memory taken up by several of traceback's module-level functions.
2021-01-14 18:45:02 -08:00
Irit Katriel 6dfd1734f5
bpo-42848: remove recursion from TracebackException (GH-24158) 2021-01-12 14:14:27 -08:00
Irit Katriel 069560b117
bpo-34463: Make python tracebacks identical to C tracebacks for SyntaxErrors without a lineno (GH-23427) 2020-12-22 21:53:09 +02:00
Irit Katriel 427613f005
bpo-42482: remove reference to exc_traceback from TracebackException (GH-23531) 2020-11-30 17:35:25 -08:00
Irit Katriel 44ca05afc8
bpo-42474: test TracebackException comparison to non-equal instances (GH-23522)
Closes bpo-42474
2020-11-27 08:38:54 -08:00
Zackery Spytz 91e93794d5
bpo-26389: Allow passing an exception object in the traceback module (GH-22610)
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>
2020-11-05 22:18:44 +00:00
Victor Stinner fabd7bb8e0
bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822)
Automerge-Triggered-By: @tiran
2020-08-11 06:26:59 -07:00
Hai Shi deb016224c
bpo-40275: Use new test.support helper submodules in tests (GH-21317) 2020-07-06 14:29:49 +02:00
Pablo Galindo 1ed83adb0e
bpo-40939: Remove the old parser (GH-20768)
This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
2020-06-11 17:30:46 +01:00
Guido van Rossum 15bc9ab301
bpo-40612: Fix SyntaxError edge cases in traceback formatting (GH-20072)
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
2020-05-14 19:22:48 -07:00
Victor Stinner 1def7754b7
bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)
* Rename PyConfig.use_peg to _use_peg_parser
* Document PyConfig._use_peg_parser and mark it a deprecated
* Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated
  in the documentation.
* Add use_old_parser() and skip_if_new_parser() to test.support
* Remove sys.flags.use_peg: use_old_parser() uses
  _testinternalcapi.get_configs() instead.
* Enhance test_embed tests
* subprocess._args_from_interpreter_flags() copies -X oldparser
2020-04-23 03:03:24 +02:00
Pablo Galindo c5fc156852
bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2020-04-22 23:29:27 +01:00
Victor Stinner c6e5c1123b
bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)
Remove:

* COUNT_ALLOCS macro
* sys.getcounts() function
* SHOW_ALLOC_COUNT code in listobject.c
* SHOW_TRACK_COUNT code in tupleobject.c
* PyConfig.show_alloc_count field
* -X showalloccount command line option
* @test.support.requires_type_collecting decorator
2020-02-03 15:17:15 +01:00
Pablo Galindo 293dd23477
Remove binding of captured exceptions when not used to reduce the chances of creating cycles (GH-17246)
Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles.

See for example GH-13135
2019-11-19 21:34:03 +00:00
Serhiy Storchaka 662db125cd
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
2019-08-08 08:42:54 +03:00
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి) 90d0cfb222 bpo-35202: Remove unused imports in tests. (GH-10561) 2018-11-16 17:32:58 +02:00
Serhiy Storchaka da8d72c953
bpo-12458: Fix line numbers for multiline expressions. (GH-8774) 2018-09-17 15:17:29 +03:00
Berker Peksag 9797b7ae44 bpo-26502: Implement FrameSummary.__len__() (GH-8632) 2018-09-10 10:02:33 -07:00
Benjamin Peterson d545869d08
bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
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.
2018-09-10 08:43:10 -07:00
Zane Bitter de86073a76 bpo-28603: Fix formatting tracebacks for unhashable exceptions (#4014) 2017-10-18 00:29:39 +03:00
codedragon 3480ef9dd3 bpo-30445: Allow appended output in RecursionError message
Running under coverage sometimes causes 'in comparison' to be added to the end of the RecursionError message, which is acceptable.

Patched by Maria Mckinley
2017-05-24 16:23:46 -05:00
Serhiy Storchaka 2b801456fb Issue #25783: Fixed test_traceback when run directly (without regrtest). 2016-10-07 23:46:22 +03:00
Serhiy Storchaka 1c1130fb5f Issue #25783: Fixed test_traceback when run directly (without regrtest). 2016-10-07 23:45:42 +03:00
Martin Panter f3b0639417 Issue #27348: Merge exception formatting fix from 3.5 into 3.6 2016-09-22 10:33:21 +00:00
Martin Panter bb8b1cb6af Issue #27348: Restore “Exception: None” formatting in traceback module
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.
2016-09-22 09:37:39 +00:00