From 4d5941d2f43f7787c4fffb182e7dcaa285f4c075 Mon Sep 17 00:00:00 2001 From: eighh1 <35957748+zx3777@users.noreply.github.com> Date: Sat, 18 Oct 2025 09:24:10 +0800 Subject: [PATCH 1/2] Fix: Resolve mmap AttributeError on Windows This fixes an `AttributeError: module 'mmap' has no attribute 'PROT_READ'` that occurs when running the script on a Windows system. The `mmap.PROT_READ` attribute is not available in Python on Windows. This commit adds an OS check to use the Windows-compatible `mmap.ACCESS_READ` parameter instead, making the tool cross-platform. --- arib/mpeg/ts.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arib/mpeg/ts.py b/arib/mpeg/ts.py index 0afa40f..af8564a 100755 --- a/arib/mpeg/ts.py +++ b/arib/mpeg/ts.py @@ -128,7 +128,13 @@ def next_packet(filename, memorymap=True): # memory map the file if necessary (prob requires 64 bit systems) _file = f if memorymap: - _file = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) + # --- START OF MODIFICATION --- + # This block checks the operating system to use the correct mmap parameter. + if os.name == 'nt': # 'nt' is the name for Windows + _file = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) + else: # For other systems like Linux or macOS + _file = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) + # --- END OF MODIFICATION --- while True: packet = _file.read(TS.PACKET_SIZE) From adb693439a32b4feb54365ff38c488b0b2e87116 Mon Sep 17 00:00:00 2001 From: John O'Neil Date: Sat, 18 Oct 2025 23:09:26 -0700 Subject: [PATCH 2/2] Apply Black tool formatting --- arib/mpeg/ts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arib/mpeg/ts.py b/arib/mpeg/ts.py index af8564a..10a63b1 100755 --- a/arib/mpeg/ts.py +++ b/arib/mpeg/ts.py @@ -130,7 +130,7 @@ def next_packet(filename, memorymap=True): if memorymap: # --- START OF MODIFICATION --- # This block checks the operating system to use the correct mmap parameter. - if os.name == 'nt': # 'nt' is the name for Windows + if os.name == "nt": # 'nt' is the name for Windows _file = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) else: # For other systems like Linux or macOS _file = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ)