Skip to content

Commit

Permalink
Raise error from stderr of Linux grabclipboard command
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Apr 24, 2023
1 parent e3cb4bb commit ab3d0c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ def grabclipboard():
msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux"
raise NotImplementedError(msg)
fh, filepath = tempfile.mkstemp()
subprocess.call(args, stdout=fh)
err = subprocess.run(args, stdout=fh, stderr=subprocess.PIPE).stderr
os.close(fh)
if err:
msg = f"{args[0]} error: {err.strip().decode()}"
raise ChildProcessError(msg)
im = Image.open(filepath)
im.load()
os.unlink(filepath)
Expand Down

0 comments on commit ab3d0c0

Please sign in to comment.