Skip to content

Python 3.14 REPL blanks links above terminal rows when pasting #135055

Description

@treyhunner

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

Activity

  1. added
    topic-replRelated to the interactive shell
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Jun 3, 2025
  2. tomasr8 commented on Jun 3, 2025

    @tomasr8
    Member

    Bisected to fac41f5 (#133247)

  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jun 7, 2025
  4. treyhunner commented on Jul 8, 2025

    @treyhunner
    MemberAuthor

    I just confirmed that this is still an issue in 3.14.0b4.

    Another way to reproduce:

    • Resize your terminal window to have few rows
    • Paste a large multi-line string
    • Resize your terminal window to be normally sized on your machine
    • Witness the blank lines above the last few rows of pasted text
    Image
  5. treyhunner commented on Sep 2, 2025

    @treyhunner
    MemberAuthor

    This is still an issue with the 3.14rc2 and this may keep me from using 3.14 while teaching. The syntax highlighting is really great, but this regression is a pretty big issue when live-coding in the REPL.

    @ambv, assuming this change in behavior was to improve performance while pasting, would not highlighting large blocks of text (or not highlighting text shown before the current terminal view) improve performance enough to allow showing the whole text block?

  6. ambv commented on Sep 15, 2025

    @ambv
    Contributor

    IPython does what we're doing now as well. Code that is outside of the visible viewport is not emitted. We are still emitting empty lines, which is in itself a bug (it's not useful and IPython doesn't do it). I'll fix that.

    The change was indeed made to make pasting faster, so I'll look into whether bulk-emitting non-highlighted code past the scrollback barrier is feasible.

  7. chris-eibl commented on Sep 16, 2025

    @chris-eibl
    Member

    Maybe emitting highlighted code past the scrollback can be done in a different paste mode like

    F4: enter "full" paste mode (press again to exit)

    and / or using CTRL-SHIFT-v (or whatever short cut seems more appropriate)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions