Skip to content

Commit

Permalink
Ignore struct.error when reading mach-o files
Browse files Browse the repository at this point in the history
  • Loading branch information
jvolkman committed Apr 24, 2023
1 parent 5b85096 commit 23520f4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/repairwheel/macos/machotools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import struct
from typing import Callable
from typing import FrozenSet
from typing import Optional
Expand All @@ -21,6 +22,10 @@
LOG = logging.getLogger(__name__)
T = TypeVar("T")

# Errors that we ignore when attempting to read files. Delocate will attempt
# to read all files (e.g., py.typed) even if they aren't dylibs.
IGNORED_READ_ERRORS = (ValueError, struct.error)

# Maps from macholib's CPU_TYPE_NAMES entry and get_cpu_subtype output to
# what lipo would print
LIPO_ARCH_NAMES = {
Expand Down Expand Up @@ -161,7 +166,7 @@ def _val(header: MachOHeader) -> Tuple[str]:
try:
macho = MachO(filename)
return _all_arches_same_value(macho, _val)
except ValueError:
except IGNORED_READ_ERRORS:
return ()


Expand Down Expand Up @@ -196,7 +201,7 @@ def _val(header: MachOHeader) -> Optional[str]:
try:
macho = MachO(filename)
return _all_arches_same_value(macho, _val)
except ValueError:
except IGNORED_READ_ERRORS:
return None


Expand Down Expand Up @@ -308,7 +313,7 @@ def _val(header: MachOHeader) -> Tuple[str]:
try:
macho = MachO(filename)
return _all_arches_same_value(macho, _val)
except ValueError:
except IGNORED_READ_ERRORS:
return ()


Expand Down

0 comments on commit 23520f4

Please sign in to comment.