Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seek relative to current position #8709

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/PIL/BufrStubImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
from __future__ import annotations

import os
from typing import IO

from . import Image, ImageFile
Expand Down Expand Up @@ -40,13 +41,11 @@ class BufrStubImageFile(ImageFile.StubImageFile):
format_description = "BUFR"

def _open(self) -> None:
offset = self.fp.tell()

if not _accept(self.fp.read(4)):
msg = "Not a BUFR file"
raise SyntaxError(msg)

self.fp.seek(offset)
self.fp.seek(-4, os.SEEK_CUR)

# make something up
self._mode = "F"
Expand Down
5 changes: 2 additions & 3 deletions src/PIL/GribStubImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
from __future__ import annotations

import os
from typing import IO

from . import Image, ImageFile
Expand Down Expand Up @@ -40,13 +41,11 @@ class GribStubImageFile(ImageFile.StubImageFile):
format_description = "GRIB"

def _open(self) -> None:
offset = self.fp.tell()

if not _accept(self.fp.read(8)):
msg = "Not a GRIB file"
raise SyntaxError(msg)

self.fp.seek(offset)
self.fp.seek(-8, os.SEEK_CUR)

# make something up
self._mode = "F"
Expand Down
5 changes: 2 additions & 3 deletions src/PIL/Hdf5StubImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
from __future__ import annotations

import os
from typing import IO

from . import Image, ImageFile
Expand Down Expand Up @@ -40,13 +41,11 @@ class HDF5StubImageFile(ImageFile.StubImageFile):
format_description = "HDF5"

def _open(self) -> None:
offset = self.fp.tell()

if not _accept(self.fp.read(8)):
msg = "Not an HDF file"
raise SyntaxError(msg)

self.fp.seek(offset)
self.fp.seek(-8, os.SEEK_CUR)

# make something up
self._mode = "F"
Expand Down
Loading