Uh oh!
There was an error while loading. Please reload this page.
gh-130168: pyrepl can messup and poll is not thread safe - #138617
gh-130168: pyrepl can messup and poll is not thread safe#138617yihong0618 wants to merge 10 commits into
Conversation
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
picnixz
commented
Sep 7, 2025
Hum, now tests fail but I don't know why. Is there another place where we use the internal state? |
yihong0618
commented
Sep 7, 2025
same like #124030 |
picnixz
commented
Sep 7, 2025
Yeah but https://github.com/python/cpython/actions/runs/17528155338/job/49781429653?pr=138617 worked and it was before my suggestions. Ok, remove the |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
yihong0618
commented
Sep 7, 2025
Done will check the test |
Mmh, so apparently the issue is indeed with the cleanup. Though I don't understand why.... because cleanups are called in LIFO. |
When I meant "remove it", I meant remove the addCleanup, but keep |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
yihong0618
commented
Sep 7, 2025
sorry for forget that, now move it back |
yihong0618
commented
Sep 7, 2025
do we need to open an issue to track this? |
yihong0618
commented
Sep 8, 2025
This patch also make #129614 the same behavior as 3.12 |
picnixz
commented
Sep 8, 2025
Maybe, but I'll need to check with a smaller reproducer. |
@picnixz after some dig found why here the issue is that we mock the it is fine but in some system like ubuntu arm 24 but this length is 20 you can use this script to check importsysimporttermiossys.path.insert(0, "./Lib")
from_pyrepl.fancy_termiosimporttcgetattr, tcsetattrdefmain():
try:
state=tcgetattr(0)
print("Real tcgetattr works, cc length:", len(state.cc))
tcsetattr(0, termios.TCSADRAIN, state)
print("Real tcsetattr works")
exceptExceptionase:
print("Error:", e)
if__name__=="__main__":
main()if we use self.addclean ... it calls the patch and the length is different so I think we add console.restore() in the last is fine |
yihong0618
commented
Sep 17, 2025
merge and fix the conflict |
interesting fail will try to figure out why fixed |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
chris-eibl
commented
Sep 23, 2025
chris-eibl
commented
Sep 23, 2025
I understand this is to be in sync what the old REPL showed, but isn't that misleading, because here |
It is, through
Mmh, then the fix should be different probably. The OP's output seems to be on darwin which is Unix-based as well. Note that In addition, on Apple terminals, line wrap is disabled so maybe something is different here as well? |
chris-eibl
commented
Sep 23, 2025
Just FTR, confirming that Windows isn't affected (since as said like on Linux no Legacy console: The prompt is overridden in this case, but this will be solved by #138732. |
yihong0618
commented
Sep 23, 2025
chris-eibl
commented
Sep 23, 2025
Oh, I know :) I was referring to
Why not just fail with "concurrent poll" - why mimic the 3.12 error message here? |
yihong0618
commented
Sep 23, 2025
sorry for the confusion next time will try to use LLM or something else to make a better desc. |
yihong0618
commented
Sep 25, 2025
yes it is mess up |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
yihong0618
commented
Sep 25, 2025
@chris-eibl now fixed the mess up can you help to check? |
chris-eibl
commented
Sep 25, 2025
Works now for me on native Ubuntu 24.04.3 LTS. |
yihong0618
commented
Sep 25, 2025
thank you for confirm the reason is that merge conflict~ |
chris-eibl
commented
Sep 25, 2025
Still unsure about the IMHO the PR would be simpler without trying to mimic it, but that's the the pyrepl maintainers decision, anyway. |
yihong0618
commented
Sep 25, 2025
the reason I choose that is make the runtime error message as basic repl |
| # Forbid re-entrant calls and use the old REPL error message. | ||
| raise RuntimeError("can't re-enter readline") |
There was a problem hiding this comment.
Yeah, maybe we can change the message. I don't have a suggestion now but I'd like REPL maintainers to first check this PR.



This fix issue 130168
but for this one it contains two issues:
the first one is for poll here is not thread safe
more can check. ##53111
and the second one is for the prepare and restore the error message will mess up.
and for the default pyrepl >= 3.13 the input is wrote in python different from the old one
this patch make the error same which is
can't re-enter readlinelike python3.12before this patch:
after this patch:

which not mess up anything
cc @gaogaotiantian can you help to check?
Thank you very much.