Fix python3 compatibility bug in spack edit command (#6748)
In Python 2, filter() returns a list, but in Python 3, filter() returns an iterator, and iterators have no length.
This commit is contained in:
parent
feb4f1b387
commit
1ce0c1b556
@ -120,8 +120,8 @@ def edit(parser, args):
|
|||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
files = glob.glob(path + '*')
|
files = glob.glob(path + '*')
|
||||||
blacklist = ['.pyc', '~'] # blacklist binaries and backups
|
blacklist = ['.pyc', '~'] # blacklist binaries and backups
|
||||||
files = filter(lambda x: all(s not in x for s in blacklist),
|
files = list(filter(
|
||||||
files)
|
lambda x: all(s not in x for s in blacklist), files))
|
||||||
if len(files) > 1:
|
if len(files) > 1:
|
||||||
m = 'Multiple files exist with the name {0}.'.format(name)
|
m = 'Multiple files exist with the name {0}.'.format(name)
|
||||||
m += ' Please specify a suffix. Files are:\n\n'
|
m += ' Please specify a suffix. Files are:\n\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user