summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_exceptions.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.9] bpo-25130: Add calls of gc.collect() in tests to support PyPy ↵Serhiy Storchaka2021-08-291-0/+10
| | | | | | (GH-28005). (GH-28028) (cherry picked from commit 2a8127cafe1d196f858a3ecabf5f1df3eebf9a12)
* [3.9] Fix the test suite for the old parser (GH-27749)Pablo Galindo Salgado2021-08-131-1/+2
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.9] bpo-33930: Fix typo in the test name. (GH-27733) (GH-27734)Miss Islington (bot)2021-08-121-1/+1
| | | | | | | | | [bpo-33930](): Fix typo in the test name. (GH-27733) (cherry picked from commit f08e6d1bb3c5655f184af88c6793e90908bb6338) Co-authored-by: Benjamin Peterson <benjamin@python.org> Automerge-Triggered-By: GH:benjaminp
* bpo-33930: Fix segfault with deep recursion when cleaning method objects ↵Miss Islington (bot)2021-08-111-0/+15
| | | | | | | (GH-27678) (GH-27720) (cherry picked from commit bfc2d5a5c4550ab3a2fadeb9459b4bd948ff61a2) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-25782: avoid hang in PyErr_SetObject when current exception has a cycle ↵Miss Islington (bot)2021-08-101-0/+142
| | | | | | | | in its context chain (GH-27626) (GH-27707) Co-authored-by: Dennis Sweeney 36520290+sweeneyde@users.noreply.github.com (cherry picked from commit d5c217475c4957a8084ac3f92ae012ece5edc7cb) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* [3.9] bpo-44409: Fix error location in tokenizer errors that happen during ↵Pablo Galindo2021-06-141-0/+1
| | | | | | | initialization (GH-26712). (GH-26723) (cherry picked from commit 507ed6fa1d6661e0f8e6d3282764aa9625a99594) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.9] bpo-43710: Rollback the 3.9 bpo-42500 fix, it broke the ABI in 3.9.3 ↵Gregory P. Smith2021-04-041-50/+2
| | | | | | | (#25179) This reverts commit 8b795ab5541d8a4e69be4137dfdc207714270b77. It changed the PyThreadState structure size, breaking the ABI in 3.9.3.
* bpo-42500: Fix recursion in or after except (GH-23568) (#24501)Mark Shannon2021-03-021-2/+50
| | | | | * Use counter, rather boolean state when handling soft overflows. (cherry picked from commit 4e7a69bdb63a104587759d7784124492dcdd496e)
* [3.9] bpo-41659: Disallow curly brace directly after primary (GH-22996) (#23006)Lysandros Nikolaou2020-10-271-0/+1
| | | (cherry picked from commit 15acc4eaba8519d7d5f2acaffde65446b44dcf79)
* [3.9] bpo-41654: Fix deallocator of MemoryError to account for subclasses ↵Pablo Galindo2020-09-011-0/+31
| | | | | | | | | | | | (GH-22020) (GH-22045) 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.. (cherry picked from commit 9b648a95ccb4c3b14f1e87158f5c9f5dbb2f62c0) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.9] bpo-40334: Produce better error messages on invalid targets (GH-20106) ↵Lysandros Nikolaou2020-06-191-1/+1
| | | | | | | | | | | | | | | | | | | (GH-20973) * bpo-40334: Produce better error messages on invalid targets (GH-20106) 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> (cherry picked from commit 01ece63d42b830df106948db0aefa6c1ba24416a)
* Use subTest in test_exceptions for better error reporting (GH-20140)Pablo Galindo2020-05-171-26/+29
|
* bpo-40619: Correctly handle error lines in programs without file mode (GH-20090)Pablo Galindo2020-05-141-0/+2
|
* bpo-40334: Always show the caret on SyntaxErrors (GH-20050)Lysandros Nikolaou2020-05-131-9/+6
| | | | | | | | | | | | | | This commit fixes SyntaxError locations when the caret is not displayed, by doing the following: - `col_number` always gets set to the location of the offending node/expr. When no caret is to be displayed, this gets achieved by setting the object holding the error line to None. - Introduce a new function `_PyPegen_raise_error_known_location`, which can be called, when an arbitrary `lineno`/`col_offset` needs to be passed. This function then gets used in the grammar (through some new macros and inline functions) so that SyntaxError locations of the new parser match that of the old.
* bpo-40334: Error message for invalid default args in function call (GH-19973)Lysandros Nikolaou2020-05-071-2/+2
| | | | | When parsing something like `f(g()=2)`, where the name of a default arg is not a NAME, but an arbitrary expression, a specialised error message is emitted.
* bpo-40334: Spacialized error message for invalid args after bare '*' (GH-19865)Lysandros Nikolaou2020-05-041-1/+1
| | | When parsing things like `def f(*): pass` the old parser used to output `SyntaxError: named arguments must follow bare *`, which the new parser wasn't able to do.
* bpo-40334: Improve column offsets for thrown syntax errors by Pegen (GH-19782)Batuhan Taskaya2020-05-011-21/+21
|
* bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)Victor Stinner2020-04-231-1/+1
| | | | | | | | | | | * 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
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-221-0/+1
| | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40335: Correctly handle multi-line strings in tokenize error scenarios ↵Pablo Galindo2020-04-211-1/+11
| | | | | (GH-19619) Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* bpo-39947: Move get_recursion_depth() to _testinternalcapi (GH-18974)Victor Stinner2020-03-131-1/+1
| | | | | Move get_recursion_depth() function from _testcapi to _testinternalcapi to avoid accessing PyThreadState attributes directly in _testcapi.
* bpo-39882: Py_FatalError() logs the function name (GH-18819)Victor Stinner2020-03-061-2/+3
| | | | | | | | | | | | The Py_FatalError() function is replaced with a macro which logs automatically the name of the current function, unless the Py_LIMITED_API macro is defined. Changes: * Add _Py_FatalErrorFunc() function. * Remove the function name from the message of Py_FatalError() calls which included the function name. * Update tests.
* bpo-39219: Fix SyntaxError attributes in the tokenizer. (GH-17828)Serhiy Storchaka2020-02-121-1/+13
| | | | * Always set the text attribute. * Correct the offset attribute for non-ascii sources.
* bpo-34880: Add the LOAD_ASSERTION_ERROR opcode. (GH-15073)Zackery Spytz2019-08-251-0/+16
| | | | Fix assert statement misbehavior if AssertionError is shadowed.
* Remove unused imports in tests (GH-14518)Victor Stinner2019-07-011-1/+1
|
* bpo-36829: Add test.support.catch_unraisable_exception() (GH-13490)Victor Stinner2019-05-221-22/+8
| | | | | | * Copy test_exceptions.test_unraisable() to test_sys.UnraisableHookTest(). * Use catch_unraisable_exception() in test_coroutines, test_exceptions, test_generators.
* bpo-31241: Fix AST node position for list and generator comprehensions. ↵Serhiy Storchaka2018-11-271-1/+1
| | | | | | | | (GH-10633) The lineno and col_offset attributes of AST nodes for list comprehensions, generator expressions and tuples are now point to the opening parenthesis or square brace. For tuples without parenthesis they point to the position of the first item.
* bpo-34683: Make SyntaxError column offsets consistently 1-indexed (gh-9338)Ammar Askar2018-09-241-0/+39
| | | | | | Also point to start of tokens in parsing errors. Fixes bpo-34683
* bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)Serhiy Storchaka2018-03-181-9/+0
|
* Fix miscellaneous typos (#4275)luzpaz2017-11-051-1/+1
|
* bpo-30697: Fix PyErr_NormalizeException() when no memory (GH-2327)xdegaye2017-10-261-2/+101
|
* bpo-30817: Fix PyErr_PrintEx() when no memory (#2526)xdegaye2017-10-231-1/+18
|
* Move exc state to generator. Fixes bpo-25612 (#1773)Mark Shannon2017-10-221-0/+56
| | | Move exception state information from frame objects to coroutine (generator/thread) object where it belongs.
* bpo-31161: only check for parens error for SyntaxError (#3082)Martijn Pieters2017-08-221-0/+28
| | | | Subclasses such as IndentError and TabError should not have this message applied.
* bpo-29951: Include function name for some error messages in ↵Michael Seifert2017-04-091-1/+1
| | | | | | | `PyArg_ParseTuple*` (#916) Also changed format specifier for function name from "%s" to "%.200s" and exception messages should start with lowercase letter.
* bpo-29998: Pickling and copying ImportError now preserves name and path (#1010)Serhiy Storchaka2017-04-081-0/+20
| | | attributes.
* bpo-20548: Use specific asserts in warnings and exceptions tests (#788)Serhiy Storchaka2017-03-301-9/+9
|
* Issue #29507: Update test_exceptionsVictor Stinner2017-02-091-9/+2
| | | | | | | | | | | | | | | | test_unraisable() of test_exceptions expects that PyErr_WriteUnraisable(method) fails on repr(method). Before the previous change (7b8df4a5d81d), slot_tp_finalize() called PyErr_WriteUnraisable() with a PyMethodObject. In this case, repr(method) calls repr(self) which is BrokenRepr.__repr__() and the calls raises a new exception. After the previous change, slot_tp_finalize() uses an unbound method: repr() is called on a regular __del__() method which doesn't call repr(self). repr() doesn't fail anymore. PyErr_WriteUnraisable() doesn't call __repr__() anymore, so remove BrokenRepr unit test.
* Issue #28289: ImportError.__init__ now resets not specified attributes.Serhiy Storchaka2016-09-281-0/+14
|
* Issue #21578: Fixed misleading error message when ImportError called withSerhiy Storchaka2016-09-271-0/+16
|\ | | | | | | invalid keyword args.
| * Issue #21578: Fixed misleading error message when ImportError called withSerhiy Storchaka2016-09-271-0/+17
|/ | | | invalid keyword args.
* Issue #22836: Keep exception reports sensible despite errorsMartin Panter2016-02-281-2/+66
|
* Issue #23391: Merge OSError doc from 3.4 into 3.5Martin Panter2015-10-261-5/+12
|\
| * Issue #23391: Restore OSError constructor argument documentationMartin Panter2015-10-261-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This restores details lost in revision 097f4fda61a4 (since Python 3.3, related to the new OSError subclasses). Further additions: * Markup for attributes and constructor signature * Explain "winerror" and "filename2" * Extend test to check for filename2 defaulting to None * Clarify that the constructor can return a subclass I have intentionally left out any details of allowing more than five arguments, or how the "args" attribute is set for four or more arguments. These details seem to be dependent on the Python version and platform.
* | Add a rudimentary test for StopAsyncIteration in test_exceptions.Yury Selivanov2015-07-031-0/+2
| |
* | Issue #19235: Add new RecursionError exception. Patch by Georg Brandl.Yury Selivanov2015-07-031-6/+7
|/
* Issue #22977: Remove unconditional import of ctypes.Serhiy Storchaka2015-04-061-1/+0
|
* Issue #22977: Fix test_exceptionsVictor Stinner2015-04-021-5/+8
|
* Issue #22977: Fixed formatting Windows error messages on Wine.Serhiy Storchaka2015-04-021-1/+9
| | | | Patch by Martin Panter.
* Issue #23353: improve exceptions tests for generatorsAntoine Pitrou2015-03-181-0/+46
|