summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-08-21 18:12:05 (GMT)
committerGitHub <noreply@github.com>2024-08-21 18:12:05 (GMT)
commitec89620e5e147ba028a46dd695ef073a72000b84 (patch)
tree93794373ed1e67fbcfbef9015fc38d94698237f8 /Lib/test/support
parenta4fd7aa4a6420cef1c22ec64eab54d8aea41cc57 (diff)
downloadcpython-ec89620e5e147ba028a46dd695ef073a72000b84.zip
cpython-ec89620e5e147ba028a46dd695ef073a72000b84.tar.gz
cpython-ec89620e5e147ba028a46dd695ef073a72000b84.tar.bz2
gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions (#123173)
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index e21a0be..19bbd40 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -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