Skip to content

Commit

Permalink
Adjust for the removal of the ABCs from the python collections module
Browse files Browse the repository at this point in the history
Python 3.10 will finally remove the long deprecated aliases to the
Abstract Base Classes from the collections module.

    https://docs.python.org/3.10/whatsnew/3.10.html#removed

Fixes MythTV#374
  • Loading branch information
garybuhrmaster committed Jul 31, 2021
1 parent 7f89299 commit ade94f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 8 additions & 5 deletions mythtv/bindings/python/MythTV/utility/dicttoxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
version = __version__

from random import randint
import collections
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import numbers
import logging
from xml.dom.minidom import parseString
Expand Down Expand Up @@ -95,7 +98,7 @@ def get_xml_type(val):
return 'null'
if isinstance(val, dict):
return 'dict'
if isinstance(val, collections.Iterable):
if isinstance(val, Iterable):
return 'list'
return type(val).__name__

Expand Down Expand Up @@ -187,7 +190,7 @@ def convert(obj, ids, attr_type, item_func, cdata, parent='root'):
if isinstance(obj, dict):
return convert_dict(obj, ids, parent, attr_type, item_func, cdata)

if isinstance(obj, collections.Iterable):
if isinstance(obj, Iterable):
return convert_list(obj, ids, parent, attr_type, item_func, cdata)

raise TypeError('Unsupported data type: %s (%s)' % (obj, type(obj).__name__))
Expand Down Expand Up @@ -231,7 +234,7 @@ def convert_dict(obj, ids, parent, attr_type, item_func, cdata):
)
)

elif isinstance(val, collections.Iterable):
elif isinstance(val, Iterable):
if attr_type:
attr['type'] = get_xml_type(val)
addline('<%s%s>%s</%s>' % (
Expand Down Expand Up @@ -294,7 +297,7 @@ def convert_list(items, ids, parent, attr_type, item_func, cdata):
)
)

elif isinstance(item, collections.Iterable):
elif isinstance(item, Iterable):
if not attr_type:
addline('<%s %s>%s</%s>' % (
item_name, make_attrstring(attr),
Expand Down
5 changes: 4 additions & 1 deletion mythtv/bindings/python/tmdb3/tmdb3/pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
# Author: Raymond Wagner
#-----------------------

from collections import Sequence, Iterator
try:
from collections.abc import Sequence, Iterator
except ImportError:
from collections import Sequence, Iterator

try:
xrange
Expand Down

0 comments on commit ade94f3

Please sign in to comment.