We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 6998f34 + d3205fa commit 9392f24Copy full SHA for 9392f24
src/PIL/ImageGrab.py
@@ -158,7 +158,8 @@ def grabclipboard():
158
159
p = subprocess.run(args, capture_output=True)
160
if p.returncode != 0:
161
- allowed_errors = [
+ err = p.stderr
162
+ for silent_error in [
163
# wl-paste, when the clipboard is empty
164
b"Nothing is copied",
165
# wl-paste/debian xclip, when an image isn't available
@@ -167,10 +168,9 @@ def grabclipboard():
167
168
b"cannot convert",
169
# xclip, when the clipboard isn't initialized
170
b"There is no owner",
- ]
171
- err = p.stderr
172
- if any(e in err for e in allowed_errors):
173
- return None
+ ]:
+ if err in silent_error:
+ return None
174
msg = f"{args[0]} error"
175
if err:
176
msg += f": {err.strip().decode()}"
0 commit comments