Commits

Fredrik Lundh committed d12f7cd

Restored pre-2.5 compatibility.

Comments (0)

Files changed (1)

     "GRIDPOINTS": lambda n: ((n) & 0xFF) << 16 # Gridpoints
 }
 
+_MAX_FLAG = 0
+for flag in FLAGS.values():
+    if isinstance(flag, type(0)):
+        _MAX_FLAG = _MAX_FLAG | flag
+
 # --------------------------------------------------------------------.
 # Experimental PIL-level API
 # --------------------------------------------------------------------.
     if type(renderingIntent) != type(1) or not (0 <= renderingIntent <=3):
         raise PyCMSError("renderingIntent must be an integer between 0 and 3")
 
-    flagsum = sum([flag if type(flag) == type(1) else 0 for flag in FLAGS.values()])
-    if type(flags) != type(1) or not (0 <= flags <=flagsum):
-        raise PyCMSError("flags must be an integer between 0 and " + flagsum)
+    if type(flags) != type(1) or not (0 <= flags <= _MAX_FLAG):
+        raise PyCMSError("flags must be an integer between 0 and %s" + _MAX_FLAG)
 
     try:
         if not isinstance(inputProfile, ImageCmsProfile):
     if type(renderingIntent) != type(1) or not (0 <= renderingIntent <=3):
         raise PyCMSError("renderingIntent must be an integer between 0 and 3")
 
-    flagsum = sum([flag if type(flag) == type(1) else 0 for flag in FLAGS.values()])
-    if type(flags) != type(1) or not (0 <= flags <=flagsum):
-        raise PyCMSError("flags must be an integer between 0 and " + flagsum)
+    if type(flags) != type(1) or not (0 <= flags <= _MAX_FLAG):
+        raise PyCMSError("flags must be an integer between 0 and %s" + _MAX_FLAG)
 
     try:
         if not isinstance(inputProfile, ImageCmsProfile):
     if type(renderingIntent) != type(1) or not (0 <= renderingIntent <=3):
         raise PyCMSError("renderingIntent must be an integer between 0 and 3")
 
-    flagsum = sum([flag if type(flag) == type(1) else 0 for flag in FLAGS.values()])
-    if type(flags) != type(1) or not (0 <= flags <=flagsum):
-        raise PyCMSError("flags must be an integer between 0 and " + flagsum)
+    if type(flags) != type(1) or not (0 <= flags <= _MAX_FLAG):
+        raise PyCMSError("flags must be an integer between 0 and %s" + _MAX_FLAG)
 
     try:
         if not isinstance(inputProfile, ImageCmsProfile):