Skip to content

Commit ab3d0c0

Browse files
committed
Raise error from stderr of Linux grabclipboard command
1 parent e3cb4bb commit ab3d0c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/PIL/ImageGrab.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ def grabclipboard():
141141
msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux"
142142
raise NotImplementedError(msg)
143143
fh, filepath = tempfile.mkstemp()
144-
subprocess.call(args, stdout=fh)
144+
err = subprocess.run(args, stdout=fh, stderr=subprocess.PIPE).stderr
145145
os.close(fh)
146+
if err:
147+
msg = f"{args[0]} error: {err.strip().decode()}"
148+
raise ChildProcessError(msg)
146149
im = Image.open(filepath)
147150
im.load()
148151
os.unlink(filepath)

0 commit comments

Comments
 (0)