ipython icon indicating copy to clipboard operation
ipython copied to clipboard

IPython `%paste` Magic Fails under Wayland

Open Alexhuszagh opened this issue 4 years ago • 2 comments

Steps to Reproduce

This reproduces under both Gnome and KDE Plasma running Wayland, however, the results are slightly different in both cases. Both the virtual, An example to reproduce this on KDE Plasma on Wayland is:

$ # Setting XDG_SESSION_TYPE is done by automatically, not explicitly, but is here for reference.
$ export XDG_SESSION_TYPE=wayland
$ python -m IPython
Python 3.9.6 (default, Jul 16 2021, 00:00:00) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.25.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %paste
UsageError: The clipboard appears to be empty

Explicitly Tested Versions

I'm running Fedora 34, and this reproduces on Linux kernel versions 5.12+, and for IPython versions 7.22-7.25 (and likely earlier, just haven't tested those). The KDE plasma versions include at least 5.21+ (and likely earlier), and the GNOME version is 40.1.0.

More Detail

The issue on KDE is that the CLIPBOARD always appears to be empty, even when it's not. Wayland does not have a concept of primary selection (see the GNOME documentation for more information), and it's trivial to verify the clipboard works both by checking a clipboard history manager or manually pasting the selection in.

On KDE, the following, non-fatal error message always occurs:

UsageError: The clipboard appears to be empty

On GNOME, a fatal error occurs, quitting the current shell, with the following output:

GNOME: XIO:  fatal IO error 25 (Inappropriate ioctl for device) on X server ":1"

Packages Installed

XWayland is installed, as are the following Wayland packages:

$ dnf list installed | grep wayland
gnome-session-wayland-session.x86_64              40.1.1-1.fc34                          @updates                                    
kf5-kwayland.x86_64                               5.84.0-1.fc34                          @copr:copr.fedorainfracloud.org:zawertun:kde
kwayland-integration.x86_64                       5.22.4-1.fc34                          @updates                                    
kwayland-server.x86_64                            5.22.4-1.fc34                          @updates                                    
kwin-wayland.x86_64                               5.22.4-1.fc34                          @updates                                    
libwayland-client.i686                            1.19.0-1.fc34                          @fedora                                     
libwayland-client.x86_64                          1.19.0-1.fc34                          @fedora                                     
libwayland-cursor.i686                            1.19.0-1.fc34                          @fedora                                     
libwayland-cursor.x86_64                          1.19.0-1.fc34                          @fedora                                     
libwayland-egl.i686                               1.19.0-1.fc34                          @fedora                                     
libwayland-egl.x86_64                             1.19.0-1.fc34                          @fedora                                     
libwayland-server.i686                            1.19.0-1.fc34                          @fedora                                     
libwayland-server.x86_64                          1.19.0-1.fc34                          @fedora                                     
plasma-workspace-wayland.x86_64                   5.22.4-1.fc34                          @updates                                    
qt5-qtwayland.x86_64                              5.15.2-7.fc34                          @updates                                    
wayland-devel.x86_64                              1.19.0-1.fc34                          @fedora                                     
xisxwayland.x86_64                                1-1.fc34                               @fedora                                     
xorg-x11-server-Xwayland.x86_64                   21.1.2-1.fc34                          @updates

Note that copr:copr is just a bleeding edge install of KDE Plasma: the official builds produce the same issues.

Alexhuszagh avatar Jul 31 '21 17:07 Alexhuszagh

Got the same issue on my Sway window manager using Wayland:

In [1]: %paste
UsageError: The clipboard appears to be empty

But %cpaste works correctly.

Any uppotunity to fix this bug?

syroezhkin avatar Sep 21 '21 13:09 syroezhkin

@Alexhuszagh , @syroezhkin , could you please check if %paste works as expected in current main? Thanks in advance!

madbird1304 avatar Sep 01 '22 20:09 madbird1304