Console Colors Cause Random Characters to be Typed

Problem description

When I use the console package in Python to log text with color to the terminal, occasionally (minutes after printing), random, color-related characters will be typed, for example ^[]4;2;0/9191/. I can delete these characters, but every once in a while more of them get typed.

Expected behavior

Characters should not be typed when console colors are used.

Actual behavior

Seemingly random characters are typed when console colors are used.

Steps to reproduce

  • Create a Python Repl
  • Install the console package
  • Type the following code:
from console import fg
print(f"{fg.lightgreen}Hello!{fg.default}")
input("Random characters will be typed here in a few minutes:")

Browser

Occurs on both Chrome and Brave

OS

Occurs on both Windows 11 and MacOS Sonoma

Device if mobile

Occurs on both Dell Inspiron 5680 and MacBook Air

Plan

Core membership

Could you please get a screenshot or screen recording of the issue happening?

3 Likes

I put my laptop to sleep and it did it when it woke up again.

That sounds like an issue with disconnecting/reconnecting then, more than a time-based thing.

2 Likes

Yeah I’d imagine you’re right.

1 Like