Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

high CPU usage and freezing in Python REPL with half space character (U+200C) #124927

Open
houshmand-2005 opened this issue Oct 3, 2024 · 4 comments
Labels
performance Performance or resource usage topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@houshmand-2005
Copy link

houshmand-2005 commented Oct 3, 2024

Bug report

Bug description:

When entering comments in Python's REPL that contain a Half Space character (U+200C) the REPL experiences 100% CPU usage and becomes unresponsive (freezes) when using the up arrow to retrieve previous code line

Steps to Reproduce:

  1. Go to Python REPL
  2. Paste the following lines (for Windows, use F3 to activate paste mode):
# Half space ‌text
# Up arrow key
  1. Press the up arrow key to navigate back to the previous line (# Half space ‌text)

(If it doesn't work for you, go to the end of the line # Up arrow key and press the up button. It should freeze now. You can use Ctrl+C to interrupt the program, which resolves the freeze.)


in terminal this looks like this:

>>> # Half space \u200ctext
... # Up arrow key

This problem also exists in Windows when using F3 (to active the paste mode):
image

In Linux no need to active paste mode:
image

image

I can't check if this problem exists on previous python version because they break each line so i cant use up arrow to go to the previous line.

Half Space character is often used in Persian and I think in other languages that utilize right-to-left . It helps in adjusting the spacing between characters for better readability


Also a small note: when I use the half space at the end and no text after it, there is no problem:

# Half space ‌
# Up arrow key

in terminal:

>>> # Half space \u200c
... # Up arrow key

System Information:

  • Linux: Python 3.13.0rc2 | Fedora 40
  • Windows Python 3.13.0rc3 | Windows 11

CPython versions tested on:

3.13

Operating systems tested on:

Linux, Windows

Linked PRs

@houshmand-2005 houshmand-2005 added the type-bug An unexpected behavior, bug, or error label Oct 3, 2024
@AlexWaygood AlexWaygood added topic-repl Related to the interactive shell performance Performance or resource usage labels Oct 3, 2024
@qqwqqw689
Copy link
Contributor

My python versoin is 3.11.5. It seems nothing happen in win10.

@skirpichev
Copy link
Member

My python versoin is 3.11.5. It seems nothing happen in win10.

Then you, probably, use old repl. I suppose OP used new repl, enabled in the CPython 3.13 by default, see: https://docs.python.org/3.13/whatsnew/3.13.html#a-better-interactive-interpreter

@ImFeH2
Copy link

ImFeH2 commented Oct 5, 2024

I hope this message finds you well. I was wondering if anyone is currently addressing this issue. If it’s alright, would it be possible for me to create a PR? I may already find the cause of the mistake.
Thank you!

@skirpichev
Copy link
Member

@ImFeH2, sure. So far nobody confirm that can reproduce issue.

Feel free to open a PR, see also https://devguide.python.org/getting-started/pull-request-lifecycle/#making-good-prs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants