gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions (#123173)

This commit is contained in:
Irit Katriel 2024-08-21 19:12:05 +01:00 committed by GitHub
parent a4fd7aa4a6
commit ec89620e5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 122 additions and 22 deletions

View file

@ -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