From 6180a7de01ba7ac95c7034622331503871f6a4c9 Mon Sep 17 00:00:00 2001 From: Michael Lockhart Date: Sat, 18 Mar 2023 20:19:46 +1100 Subject: [PATCH] Use collectiotns.abc.Iterable for type checking and flattenning In Python 3.3, the collections.Iterable class was moved into its own module Instead, now test the Abstract Base Class Iterable type. https://docs.python.org/3/library/collections.abc.html --- mcpipy/mcpi/util.py | 2 +- mcpipy/mcpi/vec3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mcpipy/mcpi/util.py b/mcpipy/mcpi/util.py index 9b9386f..1c4dea0 100644 --- a/mcpipy/mcpi/util.py +++ b/mcpipy/mcpi/util.py @@ -9,7 +9,7 @@ def flatten(l): for e in l: - if isinstance(e, collections.Iterable) and not isinstance(e, basestring): + if isinstance(e, collections.abc.Iterable) and not isinstance(e, basestring): for ee in flatten(e): yield ee else: yield e diff --git a/mcpipy/mcpi/vec3.py b/mcpipy/mcpi/vec3.py index 325ac49..46fac69 100644 --- a/mcpipy/mcpi/vec3.py +++ b/mcpipy/mcpi/vec3.py @@ -2,7 +2,7 @@ class Vec3: def __init__(self, x=0, y=0, z=0): - if isinstance(x, collections.Iterable): + if isinstance(x, collections.abc.Iterable): self.x, self.y, self.z = tuple(x) else: self.x = x