Merge pull request #7112 from radarhere/grabclipboard_stderr

This commit is contained in:
Hugo van Kemenade 2023-05-03 18:16:52 +03:00 committed by GitHub
commit 4c6159b9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)