Open
Description
Bug report
Bug description:
If you remove the ability to write ioctls to tty stdio, for example on macOS by doing
sandbox-exec -p '(version 1) (import "system.sb") (allow process-exec) (allow file-read* (subpath "/"))' python3.13
Then PyREPL fails:
Python 3.13.3 (v3.13.3:6280bb54784, Apr 8 2025, 10:47:54) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 584, in prepare
self.console.prepare()
~~~~~~~~~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line 342, in prepare
tcsetattr(self.input_fd, termios.TCSADRAIN, raw)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/fancy_termios.py", line 57, in tcsetattr
termios.tcsetattr(fd, when, attrs.as_list())
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
termios.error: (1, 'Operation not permitted')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/__main__.py", line 6, in <module>
__pyrepl_interactive_console()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/main.py", line 59, in interactive_console
run_multiline_interactive_console(console)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/simple_interact.py", line 142, in run_multiline_interactive_console
statement = multiline_input(more_lines, ps1, ps2)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/readline.py", line 389, in multiline_input
return reader.readline()
~~~~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 744, in readline
self.prepare()
~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/historical_reader.py", line 306, in prepare
super().prepare()
~~~~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 593, in prepare
self.restore()
~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line 607, in restore
self.console.restore()
~~~~~~~~~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line 372, in restore
self.__maybe_write_code(self._rmkx)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line 713, in __maybe_write_code
self.__write_code(fmt, *args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line 709, in __write_code
self.__buffer.append((curses.tparm(fmt, *args), 1))
^^^^^^^^^^^^^
AttributeError: 'UnixConsole' object has no attribute '_UnixConsole__buffer'. Did you mean: '_UnixConsole__move'?
You can work around this, by re-enabling ioctls:
sandbox-exec -p '(version 1) (import "system.sb") (allow process-exec) (allow file-read* (subpath "/")) (allow file-ioctl (regex "^/dev/ttys[0-9]*"))' python3.13
but pyrepl should probably be robust to this and fall back to a regular console.
As requested, notifying @ambv
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Metadata
Metadata
Assignees
Labels
Python modules in the Lib dirPython modules in the Lib dirRelated to the interactive shellRelated to the interactive shellAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error