Browse Source

grass.gunittest: Use collections.abc for Iterable (#2008)

Python 3.10 does not have Iterable in collections anymore and requires collections.abc.Iterable.

collections.abc is not in Python 2.7, but there are usages of collections.abc in 7.8 already in pygrass and ctypesgencore.

Backport of 60e97467f53d73c3a68681b3292826bf25d2861d (#2006) into 7.8.
Vaclav Petras 3 years ago
parent
commit
862f60f765
1 changed files with 2 additions and 2 deletions
  1. 2 2
      lib/python/gunittest/reporters.py

+ 2 - 2
lib/python/gunittest/reporters.py

@@ -17,6 +17,7 @@ import subprocess
 import sys
 import collections
 import re
+from collections.abc import Iterable
 
 from .utils import ensure_dir
 from .checkers import text_to_keyvalue
@@ -37,8 +38,7 @@ def keyvalue_to_text(keyvalue, sep='=', vsep='\n', isep=',',
     items = []
     for key, value in keyvalue.items():
         # TODO: use isep for iterables other than strings
-        if (not isinstance(value, str)
-                and isinstance(value, collections.Iterable)):
+        if not isinstance(value, str) and isinstance(value, Iterable):
             # TODO: this does not work for list of non-strings
             value = isep.join(value)
         items.append('{key}{sep}{value}'.format(