Skip to content

Commit d2d9240

Browse files
committed
Do not declare variable until necessary
1 parent b81341a commit d2d9240

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PIL/ImageGrab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def grabclipboard():
157157
raise NotImplementedError(msg)
158158

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

0 commit comments

Comments
 (0)