summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_exceptions.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-45408: Don't override previous tokenizer errors in the second parser ↵Pablo Galindo Salgado2021-10-071-1/+1
| | | | pass (GH-28812)
* bpo-45400: Fix suggestion test of test_exceptions (GH-28783)Victor Stinner2021-10-071-1/+1
| | | | | Fix test_name_error_suggestions_do_not_trigger_for_too_many_locals() of test_exceptions if a directory name contains "a1" (like "Python-3.11.0a1"): use a stricter regular expression.
* Fix typos in the Lib directory (GH-28775)Christian Clauss2021-10-061-1/+1
| | | | | Fix typos in the Lib directory as identified by codespell. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* [tests] Add missing assert against expected tracebacks in test_exceptions.py ↵andrei kulakov2021-09-211-0/+1
| | | | (GH-28484)
* bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)Serhiy Storchaka2021-08-291-0/+10
|
* bpo-44895: skip test_no_hang_on_context_chain_cycle2 until the refleak is ↵Irit Katriel2021-08-161-3/+1
| | | | fixed (GH-27761)
* bpo-44895: Temporarily add an extra gc.collect() call (GH-27746)Irit Katriel2021-08-131-0/+3
| | | This is part of an investigation of a non-deterministic reference leak. While we're looking for the root cause, this is included temporarily so that CI doesn't fail on this particular issue. This enables it to find other regressions in the meantime, which would otherwise be shadowed by our known issue.
* bpo-33930: Fix typo in the test name. (#27733)Benjamin Peterson2021-08-121-1/+1
| | | bpo-33930: Fix typo in the test name. (GH-27733)
* bpo-33930: Fix segfault with deep recursion when cleaning method objects ↵Pablo Galindo Salgado2021-08-101-0/+15
| | | | (GH-27678)
* bpo-25782: avoid hang in PyErr_SetObject when current exception has a cycle ↵Irit Katriel2021-08-101-0/+142
| | | | | in its context chain (GH-27626) Co-authored-by: Dennis Sweeney 36520290+sweeneyde@users.noreply.github.com
* bpo-34013: Don't consider a grouped expression when reporting legacy print ↵Pablo Galindo Salgado2021-08-011-0/+9
| | | | syntax errors (GH-27521)
* bpo-34013: Move the Python 2 hints from the exception constructor to the ↵Pablo Galindo Salgado2021-07-271-7/+5
| | | | parser (GH-27392)
* bpo-34013: Generalize the invalid legacy statement error message (GH-27389)Pablo Galindo Salgado2021-07-271-0/+6
|
* bpo-44655: Don't include suggestions for attributes that are the same as the ↵Pablo Galindo Salgado2021-07-161-0/+12
| | | | missing one (GH-27197)
* Remove unnecessary 'invalid_primary' rule in the parser (GH-27186)Pablo Galindo Salgado2021-07-161-1/+1
|
* bpo-44317: Improve tokenizer errors with more informative locations (GH-26555)Pablo Galindo Salgado2021-07-101-2/+2
|
* Make sure that line number is set correctly for call to __exit__ when ↵Mark Shannon2021-06-241-7/+24
| | | | handling exception in body of a with statement. (GH-26890)
* bpo-44409: Fix error location in tokenizer errors that happen during ↵Pablo Galindo2021-06-141-0/+1
| | | | initialization (GH-26712)
* bpo-44368: Ensure we don't raise incorrect custom syntax errors with soft ↵Pablo Galindo2021-06-091-0/+1
| | | | keywords (GH-26630)
* bpo-44349: Fix edge case when displaying text from files with encoding in ↵Pablo Galindo2021-06-081-0/+16
| | | | syntax errors (GH-26611)
* bpo-44335: Fix a regression when identifying invalid characters in syntax ↵Pablo Galindo2021-06-081-0/+1
| | | | errors (GH-26589)
* bpo-44180: Report generic syntax errors in the furthest position reached in ↵Pablo Galindo2021-05-211-0/+1
| | | | the first parser pass (GH-26253)
* bpo-44143: Fix crash in the parser when raising tokenizer errors with an ↵Pablo Galindo2021-05-151-0/+1
| | | | exception set (GH-26144)
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-1/+1
| | | | | | | | "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%.
* bpo-43822: Prioritize tokenizer errors over custom syntax errors when ↵Pablo Galindo2021-05-041-1/+1
| | | | raising parser exceptions (GH-25866)
* bpo-38530: Refactor and improve AttributeError suggestions (GH-25776)Dennis Sweeney2021-05-031-18/+84
| | | | | | | | | | | | | | | | | | | | - Make case-swaps half the cost of any other edit - Refactor Levenshtein code to not use memory allocator, and to bail early on no match. - Add comments to Levenshtein distance code - Add test cases for Levenshtein distance behind a debug macro - Set threshold to `(name_size + item_size + 3) * MOVE_COST / 6`. - Reasoning: similar to `difflib.SequenceMatcher.ratio()` >= 2/3: ``` "Multiset Jaccard similarity" >= 2/3 matching letters / total letters >= 2/3 (name_size - distance + item_size - distance) / (name_size + item_size) >= 2/3 1 - (2*distance) / (name_size + item_size) >= 2/3 1/3 >= (2*distance) / (name_size + item_size) (name_size + item_size) / 6 >= distance With rounding: (name_size + item_size + 3) // 6 >= distance ``` Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-43933: Show frame.f_lineno as None, rather than -1, if there is no line ↵Mark Shannon2021-04-291-1/+10
| | | | number. (GH-25717)
* bpo-38530: Require 50% similarity in NameError and AttributeError ↵Dennis Sweeney2021-04-271-0/+112
| | | | suggestions (GH-25584)
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-231-12/+143
| | | | | | | | | | | | | | | | | To improve the user experience understanding what part of the error messages associated with SyntaxErrors is wrong, we can highlight the whole error range and not only place the caret at the first character. In this way: >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^ SyntaxError: Generator expression must be parenthesized becomes >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Generator expression must be parenthesized
* bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)Pablo Galindo2021-04-211-1/+1
|
* bpo-25460: Surround suggestions by quotes (GH-25473)Pablo Galindo2021-04-191-14/+14
|
* bpo-38530: Cover more error paths in error suggestion functions (GH-25462)Pablo Galindo2021-04-171-0/+10
|
* bpo-38530: Include builtins in NameError suggestions (GH-25460)Pablo Galindo2021-04-171-4/+20
|
* bpo-38530: Match exactly AttributeError and NameError when offering ↵Pablo Galindo2021-04-161-0/+15
| | | | suggestions (GH-25443)
* bpo-38530: Make sure that failing to generate suggestions on failure will ↵Pablo Galindo2021-04-141-0/+14
| | | | not propagate exceptions (GH-25408)
* bpo-38530: Offer suggestions on NameError (GH-25397)Pablo Galindo2021-04-141-0/+123
| | | | | | | | | | | When printing NameError raised by the interpreter, PyErr_Display will offer suggestions of simmilar variable names in the function that the exception was raised from: >>> schwarzschild_black_hole = None >>> schwarschild_black_hole Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'schwarschild_black_hole' is not defined. Did you mean: schwarzschild_black_hole?
* bpo-38530: Offer suggestions on AttributeError (#16856)Pablo Galindo2021-04-141-0/+159
| | | | | | | | | When printing AttributeError, PyErr_Display will offer suggestions of similar attribute names in the object that the exception was raised from: >>> collections.namedtoplo Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you mean: namedtuple?
* bpo-43797: Improve syntax error for invalid comparisons (#25317)Pablo Galindo2021-04-121-1/+1
| | | | | | | | | | | | | * bpo-43797: Improve syntax error for invalid comparisons * Update Lib/test/test_fstring.py Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> * Apply review comments * can't -> cannot Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25142)Inada Naoki2021-04-021-2/+2
| | | | | | | | | | | | | * test__xxsubinterpreters * test_builtin * test_doctest * test_exceptions * test_opcodes * test_support * test_argparse * test_baseexception * test_bdb * test_bool * test_asdl_parser
* bpo-40176: Improve error messages for unclosed string literals (GH-19346)Batuhan Taskaya2021-01-201-2/+2
| | | Automerge-Triggered-By: GH:isidentical
* bpo-42827: Fix crash on SyntaxError in multiline expressions (GH-24140)Lysandros Nikolaou2021-01-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | When trying to extract the error line for the error message there are two distinct cases: 1. The input comes from a file, which means that we can extract the error line by using `PyErr_ProgramTextObject` and which we already do. 2. The input does not come from a file, at which point we need to get the source code from the tokenizer: * If the tokenizer's current line number is the same with the line of the error, we get the line from `tok->buf` and we're ready. * Else, we can extract the error line from the source code in the following two ways: * If the input comes from a string we have all the input in `tok->str` and we can extract the error line from it. * If the input comes from stdin, i.e. the interactive prompt, we do not have access to the previous line. That's why a new field `tok->stdin_content` is added which holds the whole input for the current (multiline) statement or expression. We can then extract the error line from `tok->stdin_content` like we do in the string case above. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly ↵Mark Shannon2020-12-171-0/+83
| | | | | | | | | after raising or reraising an exception (GH-23803) * Ensure that f_lasti is set correctly after an exception is raised to conform to PEP 626. * Update importlib * Add NEWS.
* bpo-30858: Improve error location for expressions with assignments (GH-23753)Pablo Galindo2020-12-131-1/+1
| | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-42500: Fix recursion in or after except (GH-23568)Mark Shannon2020-12-021-2/+50
| | | * Use counter, rather boolean state when handling soft overflows.
* bpo-41659: Disallow curly brace directly after primary (GH-22996)Lysandros Nikolaou2020-10-271-0/+1
|
* bpo-41654: Fix deallocator of MemoryError to account for subclasses (GH-22020)Pablo Galindo2020-09-011-0/+31
| | | | | | | When allocating MemoryError classes, there is some logic to use pre-allocated instances in a freelist only if the type that is being allocated is not a subclass of MemoryError. Unfortunately in the destructor this logic is not present so the freelist is altered even with subclasses of MemoryError.
* bpo-40275: Use new test.support helper submodules in tests (GH-21448)Hai Shi2020-08-031-3/+6
|
* bpo-40334: Produce better error messages on invalid targets (GH-20106)Lysandros Nikolaou2020-06-181-1/+1
| | | | | | | | | | | | | | The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally, a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40939: Remove the old parser (GH-20768)Pablo Galindo2020-06-111-3/+3
| | | 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.
* Use subTest in test_exceptions for better error reporting (GH-20140)Pablo Galindo2020-05-171-26/+29
|