mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions (#123173)
This commit is contained in:
parent
a4fd7aa4a6
commit
ec89620e5e
8 changed files with 122 additions and 22 deletions
|
@ -59,7 +59,8 @@ __all__ = [
|
|||
"Py_DEBUG", "exceeds_recursion_limit", "get_c_recursion_limit",
|
||||
"skip_on_s390x",
|
||||
"without_optimizer",
|
||||
"force_not_colorized"
|
||||
"force_not_colorized",
|
||||
"BrokenIter",
|
||||
]
|
||||
|
||||
|
||||
|
@ -2847,3 +2848,16 @@ def get_signal_name(exitcode):
|
|||
pass
|
||||
|
||||
return None
|
||||
|
||||
class BrokenIter:
|
||||
def __init__(self, init_raises=False, next_raises=False):
|
||||
if init_raises:
|
||||
1/0
|
||||
self.next_raises = next_raises
|
||||
|
||||
def __next__(self):
|
||||
if self.next_raises:
|
||||
1/0
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue