python-poetry / poetry-plugin-shell

MIT License
0 stars 1 forks source link

Poetry shell - Problem when erasing accented letters #20

Open Biganon opened 3 years ago

Biganon commented 3 years ago

Issue

Hi,

I create this very simple test script:

print("Enter something: ", end="")
text = input()
print(text)

When I run it from my normal shell (zsh 5.8) I can type "ééé", and then erase those three characters, end of the story.

When I run it from inside poetry shell, I can type "ééé", and then I can erase all the way to the "g" at the end of something, including it. So I can "erode" the prompt, so it looks like "Enter somethin". If I now type something, with or without accents, it will be written right after "somethin", and it will be correctly registered and printed to me. So I can read "Enter somethinhello", hit Enter, and "hello" gets printed on the next line.

The number of prompt characters I can erase depends on the number of accented letters I've entered first. If I enter four of them, such as "éééé", I can erase one character further, until it reads "Enter somethi".

sinoroc commented 3 years ago

I can recreate the issue with:

finswimmer commented 3 years ago

I have no solution for you, but I'm fascinated by this problem :) Most probably it's in encoding problem. But why does this happen only in a shell created by poetry? :thinking:

sinoroc commented 3 years ago

@finswimmer No clue either. Shells/terminals are quite tricky to tame. Did you manage to recreate the issue?

finswimmer commented 3 years ago

Yes, I'm able to reproduce it, if I start the script with poetry run ... or run poetry shell first. But I'm not able if I activate the venv with source .venv/bin/activate. So it has something to do how the shell is created.

dimbleby commented 1 year ago

this looks like a pexpect problem, maybe the same as https://github.com/pexpect/pexpect/issues/689

As there, you can recreate the issue inside the shell obtained through

python -c "import pexpect; c = pexpect.spawn('/bin/bash'); c.interact(); c.close()"
dimbleby commented 1 year ago

cf python-poetry/poetry-plugin-shell#18