Skip to content

Commit

Permalink
Merge pull request #2 from MichaelTen/MichaelTen-patch-2
Browse files Browse the repository at this point in the history
Update __init__.py
  • Loading branch information
MichaelTen authored Jan 1, 2025
2 parents f125661 + 87e4c0f commit c20d352
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pyflp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c20d352

Please sign in to comment.