You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to work on #5521 and I noticed that in the repl if you try to os.close(sys.stdout.fileno()) or more concisely os.close(1) it crashes with a Readline error: Errno(EBADF) like this:
omarabdelgawad@omarabdelgawad:~/my_workspace/RustPython$ cargo run --release Finished `release` profile [optimized] target(s) in 0.11s Running `target/release/rustpython`Welcome to the magnificent Rust Python 0.4.0 interpreter 😱 🖖RustPython 3.13.0Type "help", "copyright", "credits" or "license" for more information.>>>>> import os>>>>> os.close(1)Readline error: Errno(EBADF)omarabdelgawad@omarabdelgawad:~/my_workspace/RustPython$
Details
where with CPython it doesnt crash:
omarabdelgawad@omarabdelgawad:~$ pythonPython 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import os>>> os.close(1)>>> x = 2>>> print(x)Traceback (most recent call last): File "<stdin>", line 1, in <module>OSError: [Errno 9] Bad file descriptor>>> ^CKeyboardInterrupt>>> Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>OSError: [Errno 9] Bad file descriptoromarabdelgawad@omarabdelgawad:~$
I also noticed that even with -c "script" it kind of silently crashes:
omarabdelgawad@omarabdelgawad:~/my_workspace/RustPython$ cargo run --release -q -- -c "import os; os.close(1);print('hello')"omarabdelgawad@omarabdelgawad:~/my_workspace/RustPython$
while CPython has the same behaviour:
omarabdelgawad@omarabdelgawad:~/my_workspace/projects/github_repos/RustPython$ python -c "import os; os.close(1);print('hello')"Traceback (most recent call last): File "<string>", line 1, in <module>OSError: [Errno 9] Bad file descriptorException ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>OSError: [Errno 9] Bad file descriptor
My internet was lagging and I pressed on the submit issue button twice by mistake so there is an exact duplicate of this issue that I immediately closed #6147. please delete it if possible. I apologize for the mistake
Activity
omar-abdelgawad commentedon Sep 13, 2025
My internet was lagging and I pressed on the submit issue button twice by mistake so there is an exact duplicate of this issue that I immediately closed #6147. please delete it if possible. I apologize for the mistake
youknowone commentedon Sep 14, 2025
no worry, thank you for the report