Permalink
Browse files

Fix compiler crash with type inferencing and add all() and any() to U…

…tils
  • Loading branch information...
1 parent cbc3ddc commit ae59c5a0eb187701e88644c10511c3b05060563e @markflorisson markflorisson committed Apr 27, 2011
Showing with 21 additions and 11 deletions.
  1. +1 −1 Cython/Compiler/TypeInference.py
  2. +2 −10 Cython/Distutils/build_ext.py
  3. +18 −0 Cython/Utils.py
@@ -270,7 +270,7 @@ def resolve_dependancy(dep):
while ready_to_infer:
entry = ready_to_infer.pop()
types = [expr.infer_type(scope) for expr in entry.assignments]
- if types:
+ if Utils.all(types):
entry.type = spanning_type(types, entry.might_overflow)
else:
# FIXME: raise a warning?
@@ -19,6 +19,8 @@
from distutils.command import build_ext as _build_ext
from distutils import sysconfig
+from Cython.Utils import any
+
extension_name_re = _build_ext.extension_name_re
show_compilers = _build_ext.show_compilers
@@ -55,16 +57,6 @@ def restore_state(self):
optimization = Optimization()
-try:
- any
-except NameError:
- def any(it):
- for x in it:
- if x:
- return True
-
- return False
-
class build_ext(_build_ext.build_ext):
View
@@ -221,3 +221,21 @@ def none_or_sub(s, data):
else:
return s % data
+# all() and any() are new in 2.5
+try:
+ # Make sure to bind them on the module, as they will be accessed as
+ # attributes
+ all = all
+ any = any
+except NameError:
+ def all(items):
+ for item in items:
+ if not item:
+ return False
+ return True
+
+ def any(items):
+ for item in items:
+ if item:
+ return True
+ return False

0 comments on commit ae59c5a

Please sign in to comment.