Skip to content

Commit d8b4eae

Browse files
Sébastien Grignardjonathanslenders
authored andcommitted
fix: custom REPL input/output
1 parent 7346416 commit d8b4eae

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

ptpython/python_input.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def __init__(
324324
extra_toolbars=self._extra_toolbars,
325325
)
326326

327-
self.app = self._create_application()
327+
self.app = self._create_application(input, output)
328328

329329
if vi_mode:
330330
self.app.editing_mode = EditingMode.VI
@@ -728,7 +728,11 @@ def get_values():
728728
),
729729
]
730730

731-
def _create_application(self) -> Application:
731+
def _create_application(
732+
self,
733+
input: Optional[Input],
734+
output: Optional[Output]
735+
) -> Application:
732736
"""
733737
Create an `Application` instance.
734738
"""
@@ -758,6 +762,8 @@ def _create_application(self) -> Application:
758762
style_transformation=self.style_transformation,
759763
include_default_pygments_style=False,
760764
reverse_vi_search_direction=True,
765+
input=input,
766+
output=output,
761767
)
762768

763769
def _create_buffer(self) -> Buffer:

ptpython/repl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def compile_with_flags(code: str, mode: str):
187187
style=self._current_style,
188188
style_transformation=self.style_transformation,
189189
include_default_pygments_style=False,
190+
output=output,
190191
)
191192

192193
# If not a valid `eval` expression, run using `exec` instead.
@@ -233,6 +234,7 @@ def _handle_exception(self, e: Exception) -> None:
233234
style=self._current_style,
234235
style_transformation=self.style_transformation,
235236
include_default_pygments_style=False,
237+
output=output,
236238
)
237239

238240
output.write("%s\n" % e)

0 commit comments

Comments
 (0)