Skip to content

Commit 4466476

Browse files
committed
Fixed missing ALLOCATIONGRANULARIY in python <2.6. Python is as unportable as ever across versions with simple functionality
1 parent 9f16040 commit 4466476

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

smmap/test/test_util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from lib import TestBase, FileCreator
22

33
from smmap.util import *
4-
from mmap import ALLOCATIONGRANULARITY
54

65
import os
76
import sys

smmap/util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
import sys
44
import mmap
55

6-
from mmap import ALLOCATIONGRANULARITY, mmap, ACCESS_READ
6+
from mmap import mmap, ACCESS_READ
7+
try:
8+
from mmap import ALLOCATIONGRANULARITY
9+
except ImportError:
10+
# in python pre 2.6, the ALLOCATIONGRANULARITY does not exist as it is mainly
11+
# useful for aligning the offset. The offset argument doesn't exist there though
12+
from mmap import PAGESIZE as ALLOCATIONGRANULARITY
13+
#END handle pythons missing quality assurance
14+
715
from sys import getrefcount
816

917
__all__ = [ "align_to_mmap", "is_64_bit",

0 commit comments

Comments
 (0)