Skip to content

uv's python appears to eat ansi escape sequences on WSL? (looks like cmd.Cmd) #12465

Open
@waynew

Description

@waynew

Summary

I'm definitely seeing some weird behavior here. At first I thought it was something with uv generally, but that does not appear to be the case. I could be doing something wrong, but...

pipx install shibboleth==25.3.0b1
shibboleth

Welcome to Shibboleth 25.3.0b1, the tool designed to be *your*
secret weapon.

Your editor is currently vim. If you don't like that, you
should change or set your EDITOR environment variable.

⇀shibboleth:/home/wayne

This is the expected output. If I run

uv tool install shibboleth==25.3.0b1
shibboleth

On my Linux 6.13.8-arch1-1 x86_64 GNU/Linux machine, this works the same. However, after a pipx uninstall shibboleth

uvx --from=shibboleth==25.3.0b1 shibboleth

Welcome to Shibboleth 25.3.0b1, the tool designed to be *your*
secret weapon.

Your editor is currently vim. If you don't like that, you
should change or set your EDITOR environment variable.

⇀[34mshibboleth[0m:/home/wayne>

It appears to be escaping the ansi escape sequences. uv tool install shibboleth==25.3.0b1 has the same effect shibboleth ansi colors get borked.

But when I use my system Python:

✦ ❯ PYTHONPATH=/home/wayne/.local/share/uv/tools/shibboleth/lib64/python3.13/site-packages/ python $(which shibboleth)

Welcome to Shibboleth 25.3.0b1, the tool designed to be *your*
secret weapon.

Your editor is currently vim. If you don't like that, you
should change or set your EDITOR environment variable.

⇀shibboleth:/home/wayne
>

Everything is great!

So it appears to have something to do with uvs python. Indeed:

/home/wayne/.local/share/uv/tools/shibboleth/bin/python ~/.local/share/uv/tools/shibboleth/lib/python3.13/site-packages/shibboleth.py

is borked, but system python works.

Knowing that I went ahead and pulled some of the colorizing code from shibboleth and adapted it a bit:

print(f'\x1b[32mThis is sad\x1b[0m' )

Image

But... that worked. Putting it in a script worked. What other difference was there? OOooo. cmd.Cmd

import cmd
bad =  f'\x1b[32mThis is sad\x1b[0m'


class Ok(cmd.Cmd):
    prompt = bad

    def do_quit(self, line):
        return True

print(bad)
Ok().cmdloop()
print(bad)

Image

There it is. Something within uv doesn't play well with cmd.Cmd.

But then things get very interesting! With a lil' tweak to the script to make this clear:

Image

Interactively, the colors are correctly displayed with the uv tool python. Non-interactively? Something goes haywire, at least under WSL 🤷

If there's a command or env var, or flag I can add to the shibboleth entrypoint to try and make the colors work... let me know!

Platform

Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 GNU/Linux

Version

0.5.7

Python version

Python 3.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinguv pythonRelated to the uv python interfacewindowsSpecific to the Windows platform

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions