Merge pull request #913 from PR0M3TH3AN/refactor-imghdr-compat-16272458806887022852

🧹 Refactor imghdr compatibility hack to dedicated compat module
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-26 12:25:06 -05:00
commit 0cc36bc3f2
2 files changed
+12 -9

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
"""Compatibility layer for different Python versions."""
import sys
# Ensure the ``imghdr`` module is available for ``pgpy`` on Python 3.13+
try: # pragma: no cover - only executed on Python >= 3.13
import imghdr # type: ignore
except ModuleNotFoundError: # pragma: no cover - fallback for removed module
from utils import imghdr_stub
sys.modules.setdefault("imghdr", imghdr_stub)
+1 -9
View File
@@ -35,15 +35,7 @@ from cryptography.hazmat.primitives.asymmetric import ed25519
from cryptography.hazmat.backends import default_backend
from bip_utils import Bip39SeedGenerator
# Ensure the ``imghdr`` module is available for ``pgpy`` on Python 3.13+
try: # pragma: no cover - only executed on Python >= 3.13
import imghdr # type: ignore
except ModuleNotFoundError: # pragma: no cover - fallback for removed module
from utils import imghdr_stub as imghdr # type: ignore
import sys
sys.modules.setdefault("imghdr", imghdr)
from . import compat # noqa: F401
from local_bip85.bip85 import BIP85
from constants import (