Skip to content

prompt_toolkit: Ansi codes instead of color when an exception occurs during completion #1565

Description

@bambu

Ansi codes are displayed in the console instead of the colors when an exception occurs when tab completing. This happens on the prompt-toolkit branch. On the main branch, the exception works as expected.

Easy way to reproduce the error on the prompt-toolkit branch is by modifying argparse_completion.py with the following:

diff --git a/examples/argparse_completion.py b/examples/argparse_completion.py
index 8d2c3dca..46aa5c8d 100755
--- a/examples/argparse_completion.py
+++ b/examples/argparse_completion.py
@@ -48,6 +48,7 @@ class ArgparseCompletion(Cmd):
             "These things can\ncontain newlines and\n",
             Text("styled text!!", style=Style(color=Color.BRIGHT_YELLOW, underline=True)),
         )
+        raise Exception("poc!")

         table_item = Table(
             "Left Column",

After running the output looks like this when attempting to tab complete completion_item:

python argparse_completion.py

?[1;91mException: ?[0mpoc!

?[93mTo enable full traceback, run the following command: ?[0m?[1;36mset debug true?[0m


?[1;91mException: ?[0mpoc!

?[93mTo enable full traceback, run the following command: ?[0m?[1;36mset debug true?[0m

(Cmd) example --completion_item 

Activity

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

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions