python / python/cpython

Five curses documentation statements contradict the implementation

Đang mở
#157,140 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

docs topic-curses
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ả

Documentation

Five statements in Doc/library/curses.rst describe behaviour the module does not have.

documented says actually
halfdelay() "raise an exception if nothing has been typed" getch() returns -1
termname() "truncated to 14 characters" returns the full name
window.scroll() "no effect unless it has been enabled ... with scrollok" raises curses.error
window.insnstr() "If n is zero or negative, the entire string is inserted" zero inserts nothing
window.insch() "The cursor position does not change" the (y, x) form moves it
$ TERM=screen.xterm-256color ./python repro.py; cat out.txt
halfdelay(2); getch()   -> -1
termname()              -> b'screen.xterm-256color'
scroll() no scrollok    -> curses.error: wscrl() (called by scroll()) returned ERR
insnstr('ABC', 0)       -> '....'
insch(3, 5, ch); getyx  -> (3, 5)
repro.py
import curses

out = []
stdscr = curses.initscr()
try:
    curses.cbreak()
    curses.halfdelay(2)
    out.append(f"halfdelay(2); getch()   -> {stdscr.getch()!r}")
    curses.cbreak()
    out.append(f"termname()              -> {curses.termname()!r}")
    w = curses.newwin(5, 20, 0, 0)
    w.scrollok(False)
    try:
        w.scroll(1)
        out.append("scroll() no scrollok    -> returned None")
    except curses.error as e:
        out.append(f"scroll() no scrollok    -> curses.error: {e}")
    w.addstr(2, 0, "....")
    w.move(2, 0)
    w.insnstr("ABC", 0)
    out.append(f"insnstr('ABC', 0)       -> {w.instr(2, 0, 4).decode()!r}")
    w.insch(3, 5, ord('x'))
    out.append(f"insch(3, 5, ch); getyx  -> {w.getyx()}")
finally:
    curses.endwin()
open("out.txt", "w").write("\n".join(out) + "\n")
Linked PRs
  • gh-157141

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Mở Doc/library/curses.rst và so sánh năm phát biểu được liệt kê với các đầu ra từ repro.py. Kiểm tra PR gh-157141 được liên kết trước khi bắt đầu; công việc được coi là hoàn tất khi cả năm hành vi được tài liệu hóa đều khớp với phần triển khai được minh họa.

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
documentation
Loại issue
Tài liệu
Độ khó
1/5
Thời gian dự kiến
1-3 giờ
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
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.