Fix determining PAGESIZE under Jython (#314)
authormephi42 <mephi42@gmail.com>
Thu, 21 May 2020 12:18:17 +0000 (14:18 +0200)
committerGitHub <noreply@github.com>
Thu, 21 May 2020 12:18:17 +0000 (05:18 -0700)
Jython has neither `resource` nor `mmap`, therefore just use a
reasonable default.

elftools/elf/elffile.py

index f95fd54fb82d2538fb121eea17eb83c5a798ef1a..b7868f2e379f873f6ab9a23a35ab8e962c3c1c4f 100644 (file)
@@ -14,9 +14,13 @@ try:
     import resource
     PAGESIZE = resource.getpagesize()
 except ImportError:
-    # Windows system
-    import mmap
-    PAGESIZE = mmap.PAGESIZE
+    try:
+        # Windows system
+        import mmap
+        PAGESIZE = mmap.PAGESIZE
+    except ImportError:
+        # Jython
+        PAGESIZE = 4096
 
 from ..common.py3compat import BytesIO
 from ..common.exceptions import ELFError