Adapt configure tests to Python 3 filter API change
In Python 3, filter returns an object that can be iterated to get the filtered content. However, there is no way to reset the object, so it is useless for persistence. Spend the one iteration copying the data into a tuple, which can be iterated multiple times.
This commit is contained in:
parent
8b4586bd20
commit
6148327e4b
14
SConstruct
14
SConstruct
|
@ -3366,7 +3366,19 @@ class DXXCommon(LazyObjectConstructor):
|
|||
try:
|
||||
return tests.__configure_tests
|
||||
except AttributeError:
|
||||
tests.__configure_tests = c = filter(_filter, tests.implicit_tests + tests.custom_tests)
|
||||
# Freeze the results into a tuple, to prevent accidental
|
||||
# modification later.
|
||||
#
|
||||
# In Python 2, this is merely a safety feature and could
|
||||
# be skipped.
|
||||
#
|
||||
# In Python 3, filter returns an iterable that is
|
||||
# exhausted after one full traversal. Since this object
|
||||
# is intended to be retained and reused, the first
|
||||
# traversal must copy the results into a container that
|
||||
# can be walked multiple times. A tuple serves this
|
||||
# purpose, in addition to freezing the contents.
|
||||
tests.__configure_tests = c = tuple(filter(_filter, tests.implicit_tests + tests.custom_tests))
|
||||
return c
|
||||
@classmethod
|
||||
def __get_has_git_dir(cls):
|
||||
|
|
Loading…
Reference in a new issue