Add Python version test to detect {} in version strings.
- {} is not compatible with Python 2.6
This commit is contained in:
12
lib/spack/external/pyqver2.py
vendored
12
lib/spack/external/pyqver2.py
vendored
@@ -165,12 +165,24 @@ def visitCallFunc(self, node):
|
||||
def rollup(n):
|
||||
if isinstance(n, compiler.ast.Name):
|
||||
return n.name
|
||||
elif isinstance(n, compiler.ast.Const):
|
||||
return type(n.value).__name__
|
||||
elif isinstance(n, compiler.ast.Getattr):
|
||||
r = rollup(n.expr)
|
||||
if r:
|
||||
return r + "." + n.attrname
|
||||
name = rollup(node.node)
|
||||
if name:
|
||||
# Special handling for empty format strings, which aren't
|
||||
# allowed in Python 2.6
|
||||
if name in ('unicode.format', 'str.format'):
|
||||
n = node.node
|
||||
if isinstance(n, compiler.ast.Getattr):
|
||||
n = n.expr
|
||||
if isinstance(n, compiler.ast.Const):
|
||||
if '{}' in n.value:
|
||||
self.add(node, (2,7), name + ' with {} format string')
|
||||
|
||||
v = Functions.get(name)
|
||||
if v is not None:
|
||||
self.add(node, v, name)
|
||||
|
Reference in New Issue
Block a user