Skip to content

Commit

Permalink
Do not declare variable until necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 27, 2024
1 parent b81341a commit d2d9240
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def grabclipboard():
raise NotImplementedError(msg)

p = subprocess.run(args, capture_output=True)
err = p.stderr
if p.returncode != 0:
allowed_errors = [
# wl-paste, when the clipboard is empty
Expand All @@ -169,6 +168,7 @@ def grabclipboard():
# xclip, when the clipboard isn't initialized
b"There is no owner",
]
err = p.stderr
if any(e in err for e in allowed_errors):
return None
msg = f"{args[0]} error: {err.strip().decode() if err else 'Unknown error'}"
Expand Down

0 comments on commit d2d9240

Please sign in to comment.