Skip to content

Commit 74ce295

Browse files
committed
Simplified code
1 parent c2f1b98 commit 74ce295

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/PIL/ImageGrab.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ def grabclipboard() -> Image.Image | list[str] | None:
134134
import struct
135135

136136
o = struct.unpack_from("I", data)[0]
137-
if data[16] != 0:
138-
files = data[o:].decode("utf-16le").split("\0")
139-
else:
140-
files = data[o:].decode("mbcs").split("\0")
137+
files = data[o:].decode("mbcs" if data[16] == 0 else "utf-16le").split("\0")
141138
return files[: files.index("")]
142139
if isinstance(data, bytes):
143140
data = io.BytesIO(data)

src/PIL/JpegImagePlugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@ def validate_qtables(
831831
# in a shot. Guessing on the size, at im.size bytes. (raw pixel size is
832832
# channels*size, this is a value that's been used in a django patch.
833833
# https://github.com/matthewwithanm/django-imagekit/issues/50
834-
bufsize = 0
835834
if optimize or progressive:
836835
# CMYK can be bigger
837836
if im.mode == "CMYK":
@@ -848,7 +847,7 @@ def validate_qtables(
848847
else:
849848
# The EXIF info needs to be written as one block, + APP1, + one spare byte.
850849
# Ensure that our buffer is big enough. Same with the icc_profile block.
851-
bufsize = max(bufsize, len(exif) + 5, len(extra) + 1)
850+
bufsize = max(len(exif) + 5, len(extra) + 1)
852851

853852
ImageFile._save(
854853
im, fp, [ImageFile._Tile("jpeg", (0, 0) + im.size, 0, rawmode)], bufsize

src/libImaging/Arrow.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export_imaging_schema(Imaging im, struct ArrowSchema *schema) {
9898
}
9999

100100
/* for now, single block images */
101-
if (!(im->blocks_count == 0 || im->blocks_count == 1)) {
101+
if (im->blocks_count > 1) {
102102
return IMAGING_ARROW_MEMORY_LAYOUT;
103103
}
104104

@@ -157,7 +157,7 @@ export_single_channel_array(Imaging im, struct ArrowArray *array) {
157157
int length = im->xsize * im->ysize;
158158

159159
/* for now, single block images */
160-
if (!(im->blocks_count == 0 || im->blocks_count == 1)) {
160+
if (im->blocks_count > 1) {
161161
return IMAGING_ARROW_MEMORY_LAYOUT;
162162
}
163163

@@ -200,7 +200,7 @@ export_fixed_pixel_array(Imaging im, struct ArrowArray *array) {
200200
int length = im->xsize * im->ysize;
201201

202202
/* for now, single block images */
203-
if (!(im->blocks_count == 0 || im->blocks_count == 1)) {
203+
if (im->blocks_count > 1) {
204204
return IMAGING_ARROW_MEMORY_LAYOUT;
205205
}
206206

0 commit comments

Comments
 (0)