From fcc7058bfc272ac4a63eaf87bcd0b26e63b7eb74 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 22 Aug 2020 13:37:52 +0200 Subject: [PATCH] Fix DeprecationWarning for collections.abc DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working --- litex/gen/fhdl/verilog.py | 2 +- litex/gen/sim/core.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/litex/gen/fhdl/verilog.py b/litex/gen/fhdl/verilog.py index 98a732707..9a158147e 100644 --- a/litex/gen/fhdl/verilog.py +++ b/litex/gen/fhdl/verilog.py @@ -143,7 +143,7 @@ def _printnode(ns, at, level, node, target_filter=None): else: assignment = " <= " return "\t"*level + _printexpr(ns, node.l)[0] + assignment + _printexpr(ns, node.r)[0] + ";\n" - elif isinstance(node, collections.Iterable): + elif isinstance(node, collections.abc.Iterable): return "".join(_printnode(ns, at, level, n, target_filter) for n in node) elif isinstance(node, If): r = "\t"*level + "if (" + _printexpr(ns, node.cond)[0] + ") begin\n" diff --git a/litex/gen/sim/core.py b/litex/gen/sim/core.py index 525b4229e..ccd91e435 100644 --- a/litex/gen/sim/core.py +++ b/litex/gen/sim/core.py @@ -223,7 +223,7 @@ class Evaluator: break if not found and "default" in s.cases: self.execute(s.cases["default"]) - elif isinstance(s, collections.Iterable): + elif isinstance(s, collections.abc.Iterable): self.execute(s) elif isinstance(s, Display): args = [] @@ -275,7 +275,7 @@ class Simulator: self.generators = dict() self.passive_generators = set() for k, v in generators.items(): - if (isinstance(v, collections.Iterable) + if (isinstance(v, collections.abc.Iterable) and not inspect.isgenerator(v)): self.generators[k] = list(v) else: