handle 2.4 dependancy for builtin set
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 10 Oct 2008 09:42:55 +0000 (02:42 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 10 Oct 2008 09:42:55 +0000 (02:42 -0700)
Cython/Compiler/Builtin.py
runtests.py

index 8b9f16f77102cc82cda01330c04ce6a80404cbdc..c201db881ab504179bee470bc7f977589c1d3b45 100644 (file)
@@ -5,6 +5,7 @@
 from Symtab import BuiltinScope, StructOrUnionScope
 from TypeSlots import Signature
 import PyrexTypes
+import __builtin__
 
 builtin_function_table = [
     # name,        args,   return,  C API func,           py equiv = "*"
@@ -105,17 +106,22 @@ builtin_types_table = [
                                     ("keys",  "O",   "O", "PyDict_Keys"),
                                     ("values","O",   "O", "PyDict_Values")]),
 
-    ("set",       "PySet_Type",    [("clear",   "O",  "i", "PySet_Clear"), 
-                                    ("discard", "OO", "i", "PySet_Discard"),
-                                    ("add",     "OO", "i", "PySet_Add"),
-                                    ("pop",     "O",  "O", "PySet_Pop")]),
-    
-    ("frozenset", "PyFrozenSet_Type", []),
-
     ("slice",   "PySlice_Type",    []),
     ("file",    "PyFile_Type",     []),
 
 ]
+
+if 'set' in __builtin__.__dict__:
+    builtin_types_table += [
+        ("set",       "PySet_Type",    [("clear",   "O",  "i", "PySet_Clear"), 
+                                        ("discard", "OO", "i", "PySet_Discard"),
+                                        ("add",     "OO", "i", "PySet_Add"),
+                                        ("pop",     "O",  "O", "PySet_Pop")]),
+        
+        ("frozenset", "PyFrozenSet_Type", []),
+    ]
+
+
         
 builtin_structs_table = [
     ('Py_buffer', 'Py_buffer',
index e90c6850b06af7921b5e14976603393a98a0a892..9b511e68405ae092c0fc2bd5dac9d780f7050edc 100644 (file)
@@ -18,6 +18,10 @@ EXT_DEP_MODULES = {
     'numpy' : re.compile('.*\.numpy_.*').match
 }
 
+VER_DEP_MODULES = {
+    (2,4) : lambda x: x in ['run.set']
+}
+
 INCLUDE_DIRS = [ d for d in os.getenv('INCLUDE', '').split(os.pathsep) if d ]
 CFLAGS = os.getenv('CFLAGS', '').split()
 
@@ -417,6 +421,22 @@ class MissingDependencyExcluder:
                 return True
         return False
 
+class VersionDependencyExcluder:
+    def __init__(self, deps):
+        # deps: { version : matcher func }
+        from sys import version_info
+        self.exclude_matchers = []
+        for ver, matcher in deps.items():
+            if version_info < ver:
+                self.exclude_matchers.append(matcher)
+        self.tests_missing_deps = []
+    def __call__(self, testname):
+        for matcher in self.exclude_matchers:
+            if matcher(testname):
+                self.tests_missing_deps.append(testname)
+                return True
+        return False
+
 if __name__ == '__main__':
     from optparse import OptionParser
     parser = OptionParser()
@@ -521,7 +541,8 @@ if __name__ == '__main__':
     # which depends on them (by prefix)
 
     missing_dep_excluder = MissingDependencyExcluder(EXT_DEP_MODULES) 
-    exclude_selectors = [missing_dep_excluder] # want to pring msg at exit
+    version_dep_excluder = VersionDependencyExcluder(VER_DEP_MODULES) 
+    exclude_selectors = [missing_dep_excluder, version_dep_excluder] # want to pring msg at exit
 
     if options.exclude:
         exclude_selectors += [ re.compile(r, re.I|re.U).search for r in options.exclude ]