msvcrt.getch() returns EOF sentinel as data when no console is attached
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
"msvcrt.getch() returns EOF sentinel as data when no console is attached" --body "## Summary
On Windows, `msvcrt.getch()` returns the CRT EOF sentinel as normal Python data when no console is attached, instead of raising `OSError`.
Reproducer
```powershell
PCbuild\amd64\python_d.exe -c "import ctypes, msvcrt, sys; ctypes.windll.kernel32.FreeConsole(); sys.exit(0 if msvcrt.getch() == b'\xff' else 1)"
echo $LASTEXITCODE \``
Actual result:
`$LASTEXITCODE` is `0`
This means `msvcrt.getch()` returned `b'\xff'` after `FreeConsole()`.
Expected behavior
If `_getch()` fails because no console is attached, the Python wrapper should raise `OSError` instead of returning `b'\xff'`.
Environment
- OS: Windows 11
- Build: CPython debug build
- Command used to build: `PCbuild\build.bat -c Debug`"
CPython versions tested on:
3.15
Operating systems tested on:
Windows
Linked PRs
- gh-149450
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ entry point msvcrt.getch() và tái hiện hành vi bằng command PCbuild/amd64/python_d.exe sau FreeConsole(). Xác nhận rằng console bị thiếu không còn tạo ra b'\xff' mà thay vào đó phát sinh OSError; issue liệt kê PR được liên kết gh-149450, vì vậy trước tiên hãy kiểm tra phần việc đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- operating-systems
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100