From b66c20c201920fa7054f8481b77a038b584dc62f Mon Sep 17 00:00:00 2001 From: Michael Ten <11494798+MichaelTen@users.noreply.github.com> Date: Tue, 31 Dec 2024 19:46:05 -0800 Subject: [PATCH 1/3] Update _events.py attempting to implement a conditional fix (for affected users) regarding this issue. https://github.com/demberto/PyFLP/issues/183 --- pyflp/_events.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyflp/_events.py b/pyflp/_events.py index 1606e26..0eb94b2 100644 --- a/pyflp/_events.py +++ b/pyflp/_events.py @@ -120,7 +120,11 @@ def __init__(self, id: EventEnum, data: bytes, **kwds: Any) -> None: if len(data) != expected_size: raise InvalidEventChunkSize(expected_size, len(data)) - self.id = EventEnum(id) + # Conditional fix for Windows with Python 3.13+ + if platform.system() == "Windows" and sys.version_info >= (3, 13): + self.id = id # Apply workaround for affected environments + else: + self.id = EventEnum(id) # Default behavior for unaffected environments self._kwds = kwds self.value = self.STRUCT.parse(data, **self._kwds) From 87e4c0fe43e85700338dacf71139521cc7244ee5 Mon Sep 17 00:00:00 2001 From: Michael Ten <11494798+MichaelTen@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:10:01 -0800 Subject: [PATCH 2/3] Update __init__.py attempting to implement a conditional fix (for affected users) regarding this issue. https://github.com/demberto/PyFLP/issues/183 --- pyflp/__init__.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pyflp/__init__.py b/pyflp/__init__.py index 2029980..05f57f7 100644 --- a/pyflp/__init__.py +++ b/pyflp/__init__.py @@ -120,8 +120,11 @@ def parse(file: pathlib.Path | str) -> Project: stream.seek(22) # Back to start of events while stream.tell() < file_size: event_type: type[AnyEvent] | None = None - id = EventEnum(int.from_bytes(stream.read(1), "little")) - + # Conditional fix for Windows with Python 3.13+ + if platform.system() == "Windows" and sys.version_info >= (3, 13): + id = int.from_bytes(stream.read(1)) # Workaround for affected environments + else: + id = EventEnum(int.from_bytes(stream.read(1), "little")) # Default behavior if id < WORD: value = stream.read(1) elif id < DWORD: @@ -151,9 +154,16 @@ def parse(file: pathlib.Path | str) -> Project: event_type = U16Event elif id < TEXT: event_type = U32Event - elif id < DATA or id.value in NEW_TEXT_IDS: - if str_type is None: # pragma: no cover - raise VersionNotDetected # ! This should never happen + # Conditional fix for Windows with Python 3.13+ + elif platform.system() == "Windows" and sys.version_info >= (3, 13): + if id < DATA or id in NEW_TEXT_IDS: # Workaround for affected environments + if str_type is None: # pragma: no cover + raise VersionNotDetected # ! This should never happen + event_type = str_type + # Default behavior for unaffected users + elif id < DATA or id.value in NEW_TEXT_IDS: # Original logic retained + if str_type is None: # pragma: no cover + raise VersionNotDetected # ! This should never happen event_type = str_type if id == PluginID.InternalName: From 323825e48370364038080bcdfaf3f2d2043cad6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 04:22:37 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyflp/_events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyflp/_events.py b/pyflp/_events.py index 0eb94b2..24107b8 100644 --- a/pyflp/_events.py +++ b/pyflp/_events.py @@ -120,7 +120,7 @@ def __init__(self, id: EventEnum, data: bytes, **kwds: Any) -> None: if len(data) != expected_size: raise InvalidEventChunkSize(expected_size, len(data)) - # Conditional fix for Windows with Python 3.13+ + # Conditional fix for Windows with Python 3.13+ if platform.system() == "Windows" and sys.version_info >= (3, 13): self.id = id # Apply workaround for affected environments else: