Skip to content

Commit

Permalink
Apply patch from upstream to support Python 3.8
Browse files Browse the repository at this point in the history
Apply saltstack/salt#56031 to support Python 3.8, which removed a
deprecated module and changed some behaviour. Add a {Build,}Requires on
python-distro, since it is now required.
  • Loading branch information
s-t-e-v-e-n-k authored and meaksh committed Mar 24, 2020
1 parent 07a5c01 commit 1cc7648
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pkg/suse/salt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ BuildRequires: python-psutil
BuildRequires: python-requests >= 1.0.0
BuildRequires: python-tornado >= 4.2.1
BuildRequires: python-yaml
BuildRequires: python-distro
# requirements/opt.txt (not all)
# BuildRequires: python-MySQL-python
# BuildRequires: python-timelib
Expand Down Expand Up @@ -112,6 +113,7 @@ Requires: python-psutil
Requires: python-requests >= 1.0.0
Requires: python-tornado >= 4.2.1
Requires: python-yaml
Requires: python-distro
%if 0%{?suse_version}
# requirements/opt.txt (not all)
Recommends: python-MySQL-python
Expand Down
4 changes: 3 additions & 1 deletion salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3196,7 +3196,9 @@ def apply_cloud_providers_config(overrides, defaults=None):
# Merge provided extends
keep_looping = False
for alias, entries in six.iteritems(providers.copy()):
for driver, details in six.iteritems(entries):
for driver in list(six.iterkeys(entries)):
# Don't use iteritems, because the values of the dictionary will be changed
details = entries[driver]

if 'extends' not in details:
# Extends resolved or non existing, continue!
Expand Down
16 changes: 8 additions & 8 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
__proxyenabled__ = ['*']
__FQDN__ = None

# Extend the default list of supported distros. This will be used for the
# /etc/DISTRO-release checking that is part of linux_distribution()
from platform import _supported_dists
_supported_dists += ('arch', 'mageia', 'meego', 'vmware', 'bluewhite64',
'slamd64', 'ovs', 'system', 'mint', 'oracle', 'void')

# linux_distribution deprecated in py3.7
try:
from platform import linux_distribution as _deprecated_linux_distribution

# Extend the default list of supported distros. This will be used for the
# /etc/DISTRO-release checking that is part of linux_distribution()
from platform import _supported_dists
_supported_dists += ('arch', 'mageia', 'meego', 'vmware', 'bluewhite64',
'slamd64', 'ovs', 'system', 'mint', 'oracle', 'void')

def linux_distribution(**kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return _deprecated_linux_distribution(**kwargs)
return _deprecated_linux_distribution(supported_dists=_supported_dists, **kwargs)
except ImportError:
from distro import linux_distribution

Expand Down Expand Up @@ -1976,7 +1976,7 @@ def os_data():
)
(osname, osrelease, oscodename) = \
[x.strip('"').strip("'") for x in
linux_distribution(supported_dists=_supported_dists)]
linux_distribution()]
# Try to assign these three names based on the lsb info, they tend to
# be more accurate than what python gets from /etc/DISTRO-release.
# It's worth noting that Ubuntu has patched their Python distribution
Expand Down
8 changes: 4 additions & 4 deletions salt/renderers/stateconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ def process_high_data(high, extract):
tmplctx = STATE_CONF.copy()
if tmplctx:
prefix = sls + '::'
for k in six.iterkeys(tmplctx): # iterate over a copy of keys
if k.startswith(prefix):
tmplctx[k[len(prefix):]] = tmplctx[k]
del tmplctx[k]
tmplctx = {
k[len(prefix):] if k.startswith(prefix) else k: v
for k, v in six.iteritems(tmplctx)
}
else:
tmplctx = {}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/modules/test_virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def test_update(self):
<alias name='net1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x1'/>
</interface>
<graphics type='spice' port='5900' autoport='yes' listen='127.0.0.1'>
<graphics type='spice' listen='127.0.0.1' autoport='yes'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<video>
Expand Down

0 comments on commit 1cc7648

Please sign in to comment.