Skip to content

ValueError: Bad Args PS1 object – when using VSCode Python extension v2024.0.0 or newer #1041

Closed

Description

@interDist

Within the terminal panel of VSCode with Python extension enabled:

>>> python -m pip show bpython curtsies
Name: bpython
Version: 0.21
Summary: Fancy Interface to the Python Interpreter
Requires: curtsies, cwcwidth, greenlet, pygments, pyxdg, requests
Required-by: 
---
Name: curtsies
Version: 0.4.0
Summary: Curses-like terminal wrapper, with colored strings!
Requires: blessed, cwcwidth
Required-by: bpython

>>> bpython
bpython version 0.21 on top of Python 3.12.3 /root/.venvs/p312/bin/python3

Traceback (most recent call last):
  File "/root/.venvs/p312/bin/bpython", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsies.py", line 201, in main
    exit_value = repl.mainloop(True, paste)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsies.py", line 113, in mainloop
    self.process_event_and_paint(None)
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsies.py", line 95, in process_event_and_paint
    array, cursor_pos = self.paint()
                        ^^^^^^^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsiesfrontend/repl.py", line 1468, in paint
    min_height, width, self.current_cursor_line
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsiesfrontend/repl.py", line 1374, in current_cursor_line
    return self.current_cursor_line_without_suggestion + suggest(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsiesfrontend/repl.py", line 1363, in current_cursor_line_without_suggestion
    "" if self.coderunner.running else self.display_line_with_prompt
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/bpython/curtsiesfrontend/repl.py", line 1352, in display_line_with_prompt
    prompt(self.ps1) if self.done else more(self.ps2)
    ^^^^^^^^^^^^^^^^
  File "/root/.venvs/p312/lib/python3.12/site-packages/curtsies/formatstring.py", line 883, in fmtstr
    raise ValueError(
ValueError: Bad Args: <__main__.PS1 object at 0x76bb09ea1550> (of type <class '__main__.PS1'>), (), {'fg': 36, 'bold': False}

Activity

  1. chet-manley commented on Sep 18, 2025

    @chet-manley

    Just ran into this same issue using Python 3.13.7 and bpython 0.25.

  2. sebastinas commented on Sep 20, 2025

    @sebastinas
    Contributor

    I am unable to reproduce the issue. Do you set PS1 to some specific value?

  3. added theissue type on Sep 20, 2025
  4. paranoik1 commented on Sep 23, 2025

    @paranoik1

    A similar problem occurs when running bpython in VSCode.

    bpython version 0.25 on top of Python 3.13.7 /home/q/.local/share/pipx/venvs/bpython/bin/python
    
    Traceback (most recent call last):
      File "/home/q/.local/bin/bpython", line 8, in <module>
        sys.exit(main())
                 ~~~~^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsies.py", line 245, in main
        repl.mainloop(True, paste)
        ~~~~~~~~~~~~~^^^^^^^^^^^^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsies.py", line 170, in mainloop
        self.process_event_and_paint(None)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsies.py", line 148, in process_event_and_paint
        array, cursor_pos = self.paint()
                            ~~~~~~~~~~^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1611, in paint
        min_height, width, self.current_cursor_line
                           ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1517, in current_cursor_line
        return self.current_cursor_line_without_suggestion + suggest(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1506, in current_cursor_line_without_suggestion
        "" if self.coderunner.running else self.display_line_with_prompt
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1495, in display_line_with_prompt
        prompt(self.ps1) if self.done else more(self.ps2)
        ~~~~~~^^^^^^^^^^
      File "/home/q/.local/share/pipx/venvs/bpython/lib/python3.13/site-packages/curtsies/formatstring.py", line 868, in fmtstr
        raise ValueError(
            f"Bad Args: {string!r} (of type {type(string)}), {args!r}, {kwargs!r}"
        )
    ValueError: Bad Args: <__main__.PS1 object at 0x7f6297e402f0> (of type <class '__main__.PS1'>), (), {'fg': 36, 'bold': False}
    

    In the kitty terminal, the startup is successful:

    ~ ᐅ bpython
    bpython version 0.25 on top of Python 3.13.7 /home/q/.local/share/pipx/venvs/bpython/bin/python
    >>> 
    
  5. emberquill commented on Sep 23, 2025

    @emberquill

    I think it's something relating to VSCode. I've gotten the error in VSCode's integrated terminal on two different computers (one Linux, one Mac) but not in any other terminal emulator. And in VSCode I get the same error regardless of the shell environment. Even happened in a bash --noprofile --norc session:

    bash-5.3$ uv run --with bpython bpython
    bpython version 0.25 on top of Python 3.13.7 /home/emberquill/.cache/uv/builds-v0/.tmpwSeVZH/bin/python
    
    Traceback (most recent call last):
      File "/home/emberquill/.cache/uv/builds-v0/.tmpwSeVZH/bin/bpython", line 10, in <module>
        sys.exit(main())
                 ~~~~^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsies.py", line 245, in main
        repl.mainloop(True, paste)
        ~~~~~~~~~~~~~^^^^^^^^^^^^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsies.py", line 170, in mainloop
        self.process_event_and_paint(None)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsies.py", line 148, in process_event_and_paint
        array, cursor_pos = self.paint()
                            ~~~~~~~~~~^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1611, in paint
        min_height, width, self.current_cursor_line
                           ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1517, in current_cursor_line
        return self.current_cursor_line_without_suggestion + suggest(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1506, in current_cursor_line_without_suggestion
        "" if self.coderunner.running else self.display_line_with_prompt
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 1495, in display_line_with_prompt
        prompt(self.ps1) if self.done else more(self.ps2)
        ~~~~~~^^^^^^^^^^
      File "/home/emberquill/.cache/uv/archive-v0/0r178DEbVx0TTGhkxMmvD/lib/python3.13/site-packages/curtsies/formatstring.py", line 868, in fmtstr
        raise ValueError(
            f"Bad Args: {string!r} (of type {type(string)}), {args!r}, {kwargs!r}"
        )
    ValueError: Bad Args: <__main__.PS1 object at 0x7ff768e1c1a0> (of type <class '__main__.PS1'>), (), {'fg': 36, 'bold': False}
    
  6. emberquill commented on Sep 23, 2025

    @emberquill

    Actually, it only happens with the Microsoft Python extension in VSCode. It does something weird to sys.ps1:

    Regular terminal:

    >>> sys.ps1
    '>>> '
    >>> type(sys.ps1)
    <class 'str'>

    VSCode terminal with Python extension:

    >>> sys.ps1
    <__main__.PS1 object at 0x7fe2b901d400>
    >>> type(sys.ps1)
    <class '__main__.PS1'>
    >>> str(sys.ps1)
    '\x1b]633;C\x07\x1b]633;E;str(sys.ps1)\x07\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07'

    Edit: looks like the extension changes the PYTHONSTARTUP environment variable to point at its own pythonrc.py that changes sys.ps1 here.

  7. added this to the release-0.26 milestone on Sep 24, 2025
  8. removed
    moreinfoMore information required from the submitter
    on Sep 24, 2025
  9. interDist commented on Sep 24, 2025

    @interDist
    Author

    @emberquill You are complete right! I am no longer using terminal in standalone mode, only through VSCode, and did not realize that VSCode is doing something weird with it... So the issue was not in upgrading Python but rather the version of the VSCode Python extension.

    Ref https://github.com/microsoft/vscode-python/releases/tag/v2024.0.0 and microsoft/vscode-python@1ea53e2

  10. changed the title [-]ValueError: Bad Args PS1 object – on python 3.12[/-] [+]ValueError: Bad Args PS1 object – when using VSCode Python extension v2024.0.0 or newer[/+] on Sep 24, 2025
  11. added a commit that references this issue on Sep 24, 2025
    3e430e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions