Skip to content

Commit

Permalink
Merge pull request #7112 from radarhere/grabclipboard_stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored May 3, 2023
2 parents 7ec3f8c + ab3d0c0 commit 4c6159b
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 4c6159b

Please sign in to comment.