Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pyrepl fails with an ugly traceback when ioctls are not allowed on tty stdio #134466

Open
Labels
stdlibPython modules in the Lib dirtopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error
@glyph

Description

@glyph

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp