Skip to content

Commit 1afbf64

Browse files
cool-RRjonathanslenders
authored andcommitted
Fix exception causes all over the codebase
1 parent beb9b26 commit 1afbf64

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

prompt_toolkit/input/vt100.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def __init__(self, stdin: TextIO) -> None:
4848
try:
4949
# This should not raise, but can return 0.
5050
stdin.fileno()
51-
except io.UnsupportedOperation:
51+
except io.UnsupportedOperation as e:
5252
if "idlelib.run" in sys.modules:
5353
raise io.UnsupportedOperation(
5454
"Stdin is not a terminal. Running from Idle is not supported."
55-
)
55+
) from e
5656
else:
57-
raise io.UnsupportedOperation("Stdin is not a terminal.")
57+
raise io.UnsupportedOperation("Stdin is not a terminal.") from e
5858

5959
# Even when we have a file descriptor, it doesn't mean it's a TTY.
6060
# Normally, this requires a real TTY device, but people instantiate

prompt_toolkit/key_binding/bindings/named_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def get_by_name(name: str) -> Binding:
5555
"""
5656
try:
5757
return _readline_commands[name]
58-
except KeyError:
59-
raise KeyError("Unknown Readline command: %r" % name)
58+
except KeyError as e:
59+
raise KeyError("Unknown Readline command: %r" % name) from e
6060

6161

6262
#

prompt_toolkit/layout/layout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def __init__(
5959
if focused_element is None:
6060
try:
6161
self._stack.append(next(self.find_all_windows()))
62-
except StopIteration:
62+
except StopIteration as e:
6363
raise InvalidLayoutError(
6464
"Invalid layout. The layout does not contain any Window object."
65-
)
65+
) from e
6666
else:
6767
self.focus(focused_element)
6868

0 commit comments

Comments
 (0)