Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
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 darwinType "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", line584, inprepareself.console.prepare()~~~~~~~~~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line342, inprepare tcsetattr(self.input_fd, termios.TCSADRAIN, raw)~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/fancy_termios.py", line57, intcsetattr 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>", line198, in_run_module_as_main File"<frozen runpy>", line88, in_run_code File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/__main__.py", line6, in<module> __pyrepl_interactive_console()~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/main.py", line59, ininteractive_console run_multiline_interactive_console(console)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/simple_interact.py", line142, inrun_multiline_interactive_console statement= multiline_input(more_lines, ps1, ps2) File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/readline.py", line389, inmultiline_inputreturn reader.readline()~~~~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line744, inreadlineself.prepare()~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/historical_reader.py", line306, inpreparesuper().prepare()~~~~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line593, inprepareself.restore()~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/reader.py", line607, inrestoreself.console.restore()~~~~~~~~~~~~~~~~~~~~^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line372, inrestoreself.__maybe_write_code(self._rmkx)~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line713, in__maybe_write_codeself.__write_code(fmt,*args)~~~~~~~~~~~~~~~~~^^^^^^^^^^^^ File"/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/_pyrepl/unix_console.py", line709, in__write_codeself.__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