提交 e82d211c authored 作者: Joseph Turian's avatar Joseph Turian

Python 2.4 backport

上级 7b540b1e
...@@ -43,7 +43,8 @@ def stack_search(start, expand, mode='bfs', build_inv = False): ...@@ -43,7 +43,8 @@ def stack_search(start, expand, mode='bfs', build_inv = False):
raise ValueError('mode should be bfs or dfs', mode) raise ValueError('mode should be bfs or dfs', mode)
rval_set = set() rval_set = set()
rval_list = list() rval_list = list()
start_pop = start.popleft if mode is 'bfs' else start.pop if mode is 'bfs': start_pop = start.popleft
else: start_pop = start.pop
expand_inv = {} expand_inv = {}
while start: while start:
l = start_pop() l = start_pop()
...@@ -91,7 +92,8 @@ def results_and_orphans(r_in, r_out, except_unreachable_input=False): ...@@ -91,7 +92,8 @@ def results_and_orphans(r_in, r_out, except_unreachable_input=False):
if io in r_in_set: if io in r_in_set:
return None return None
try: try:
return [io.owner] if io.owner != None else None if io.owner != None: return [io.owner]
else: return None
except AttributeError: except AttributeError:
return io.inputs return io.inputs
ops_and_results, dfsinv = stack_search( ops_and_results, dfsinv = stack_search(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论