python / python/cpython

Python 3.14 REPL blanks links above terminal rows when pasting

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

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

3.14 3.15 stdlib topic-repl type-bug
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:

In Python 3.14 beta 2, pasting code that has more lines than the height of my terminal window will result in the lines just above the terminal window being blank.

To reproduce:

  1. Resize your terminal so the height is approximately 20 rows
  2. Paste the below block of Python code.
  3. Scroll up in your terminal to see previous lines above the last 20 rows
  4. Note that all rows above the terminal screen are blank (no class Point: line or __slots__ line for example)
class Point:
    __slots__ = ('x', 'y')
    __match_args__ = ('x', 'y')

    def __init__(self, x: float, y: float) -> None:
        object.__setattr__(self, 'x', x)
        object.__setattr__(self, 'y', y)

    def __repr__(self):
        cls = type(self).__name__
        return f'{cls}(x={self.x!r}, y={self.y!r})'

    def __eq__(self, other):
        if not isinstance(other, Point):
            return NotImplemented
        return (self.x, self.y) == (other.x, other.y)

    def __hash__(self):
        return hash((self.x, self.y))

    def __setattr__(self, name, value):
        raise AttributeError(f"Can't set attribute {name!r}")

    def __delattr__(self, name):
        raise AttributeError(f"Can't delete attribute {name!r}")

    def __getstate__(self):
        return (self.x, self.y)

    def __setstate__(self, state):
        fields = ('x', 'y')
        for field, value in zip(fields, state):
            object.__setattr__(self, field, value)

This is essentially the same as the "Blank lines" section of issue #119517.

I assume this is being done for performance reasons, but this is going to make my life harder when teaching. I often use a large font when teaching, so it's not uncommon that I'll paste a block of code that is longer than the terminal height. Being able to scroll up and show my students what was pasted is an essential feature for me when teaching.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

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

Tái hiện hành vi của Python 3.14 REPL trong một terminal Linux được thay đổi kích thước còn khoảng 20 dòng, sử dụng ví dụ được dán từ issue này. Đọc phần “Blank lines” của issue #119517 để biết ngữ cảnh liên quan, sau đó xác minh rằng các dòng được dán phía trên viewport của terminal vẫn hiển thị khi cuộn ngược lại.

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
cli
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
Khá rõ ràng
Mức phù hợp với người mới
45/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.