浏览代码

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 年之前
父节点
当前提交
862f60f765
共有 1 个文件被更改,包括 2 次插入2 次删除
  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(