From: Robert Bradshaw Date: Fri, 10 Oct 2008 09:42:55 +0000 (-0700) Subject: handle 2.4 dependancy for builtin set X-Git-Tag: 0.9.9.2.beta~44 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b3004f5d067848fc056de2c138ca95936fb5f810;p=cython.git handle 2.4 dependancy for builtin set --- diff --git a/Cython/Compiler/Builtin.py b/Cython/Compiler/Builtin.py index 8b9f16f7..c201db88 100644 --- a/Cython/Compiler/Builtin.py +++ b/Cython/Compiler/Builtin.py @@ -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', diff --git a/runtests.py b/runtests.py index e90c6850..9b511e68 100644 --- a/runtests.py +++ b/runtests.py @@ -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 ]