The backports should be conditional - this throws errors for ARM on py3.12+
Site packages contain compiled extensions with mismatched architecture. Expected x86_64, found:
- .../python3.12/site-packages/backports/_datetime_fromisoformat.cpython-312-darwin.so: .../python3.12/site-packages/backports/_datetime_fromisoformat.cpython-312-darwin.so: Mach-O 64-bit bundle arm64
|
# Remove when dropping Python 3.10 |
|
try: |
|
from backports.datetime_fromisoformat import MonkeyPatch |
|
except ImportError: |
|
pass |
|
else: |
|
MonkeyPatch.patch_fromisoformat() |
Recommend adding a Python version check to only import backports.datetime_fromisoformat for Python < 3.11.
Currently, marshmallow unconditionally attempts to import the backport (and its compiled extension), which is not needed or appropriate for Python 3.11+ (where datetime.fromisoformat is built-in). On Python 3.12 ARM Macs, this can fail at load time due to a Mach-O architecture mismatch (arm64 vs x86_64) for the compiled extension.
Suggested fix:
import sys
# Remove when dropping Python 3.10
if sys.version_info < (3, 11):
try:
from backports.datetime_fromisoformat import MonkeyPatch
except ImportError:
pass
else:
MonkeyPatch.patch_fromisoformat()
This ensures the patch is only attempted on versions that actually require it, avoiding both unnecessary imports and potential architecture errors on newer Python versions.
The backports should be conditional - this throws errors for ARM on py3.12+
Site packages contain compiled extensions with mismatched architecture. Expected x86_64, found:
marshmallow/src/marshmallow/fields.py
Lines 23 to 29 in 27bfa77
Recommend adding a Python version check to only import backports.datetime_fromisoformat for Python < 3.11.
Currently, marshmallow unconditionally attempts to import the backport (and its compiled extension), which is not needed or appropriate for Python 3.11+ (where datetime.fromisoformat is built-in). On Python 3.12 ARM Macs, this can fail at load time due to a Mach-O architecture mismatch (arm64 vs x86_64) for the compiled extension.
Suggested fix:
This ensures the patch is only attempted on versions that actually require it, avoiding both unnecessary imports and potential architecture errors on newer Python versions.