mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-06 04:43:10 +03:00
Do not declare variable until necessary
This commit is contained in:
parent
b81341ae7e
commit
d2d9240de4
|
@ -157,7 +157,6 @@ def grabclipboard():
|
||||||
raise NotImplementedError(msg)
|
raise NotImplementedError(msg)
|
||||||
|
|
||||||
p = subprocess.run(args, capture_output=True)
|
p = subprocess.run(args, capture_output=True)
|
||||||
err = p.stderr
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
allowed_errors = [
|
allowed_errors = [
|
||||||
# wl-paste, when the clipboard is empty
|
# wl-paste, when the clipboard is empty
|
||||||
|
@ -169,6 +168,7 @@ def grabclipboard():
|
||||||
# xclip, when the clipboard isn't initialized
|
# xclip, when the clipboard isn't initialized
|
||||||
b"There is no owner",
|
b"There is no owner",
|
||||||
]
|
]
|
||||||
|
err = p.stderr
|
||||||
if any(e in err for e in allowed_errors):
|
if any(e in err for e in allowed_errors):
|
||||||
return None
|
return None
|
||||||
msg = f"{args[0]} error: {err.strip().decode() if err else 'Unknown error'}"
|
msg = f"{args[0]} error: {err.strip().decode() if err else 'Unknown error'}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user