Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic: Support for Python 3.8 #55835

Closed
sagetherage opened this issue Jan 10, 2020 · 9 comments · Fixed by #57240
Closed

Epic: Support for Python 3.8 #55835

sagetherage opened this issue Jan 10, 2020 · 9 comments · Fixed by #57240
Assignees
Labels
Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Epic ZRelease-Sodium retired label
Milestone

Comments

@sagetherage
Copy link
Contributor

sagetherage commented Jan 10, 2020

Description of Issue

Epic or bucket ticket for tasks for supporting Python 3.8 changes going forward, as an epic this ticket may span more than one release over time.

Related ticket(s):

@Ch3LL
Copy link
Contributor

Ch3LL commented Jan 29, 2020

Deprecation Warnings that need to be cleaned up

@bdrung
Copy link
Contributor

bdrung commented Jan 30, 2020

#55976 is a duplicate of #50911, which is addressed in pull request #56027

@bdrung
Copy link
Contributor

bdrung commented Feb 3, 2020

I pushed more commits to pull request #56031. Now it fixes all Python 3.8 unit test failures. So after backporting these commits, the Debian package 2019.2.3+dfsg1-2 will build on Ubuntu 20.04 (which contains Python 3.8).

@s0undt3ch
Copy link
Collaborator

Related #55900

@s0undt3ch
Copy link
Collaborator

For anyone working on Py3.8 support, some work has been done in https://github.com/saltstack/salt/tree/features/py38-compat?files=1

@stale

This comment has been minimized.

@stale stale bot added the stale label Mar 17, 2020
@baby-gnu

This comment has been minimized.

@stale

This comment has been minimized.

@stale stale bot removed the stale label Mar 18, 2020
@sagetherage sagetherage added Confirmed Salt engineer has confirmed bug/feature - often including a MCVE ZRelease-Sodium retired label labels Mar 24, 2020
bdrung added a commit to bdrung/salt that referenced this issue Apr 24, 2020
Salt fails on Python 3.8:

```
======================================================================
ERROR: unit.grains.test_core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: unit.grains.test_core
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "tests/unit/grains/test_core.py", line 37, in <module>
    import salt.grains.core as core
  File "salt/grains/core.py", line 40, in <module>
    from platform import _supported_dists
ImportError: cannot import name '_supported_dists' from 'platform' (/usr/lib/python3.8/platform.py)
```

So only try to import `_supported_dists` from `platform` for Python <=
3.7. Otherwise rely on the external `distro` module to  not need any
special handling.

Addresses parts of saltstack#55835
Signed-off-by: Benjamin Drung <[email protected]>
@twangboy

This comment has been minimized.

@sagetherage sagetherage assigned waynew and s0undt3ch and unassigned Ch3LL, sagetherage and waynew May 5, 2020
s0undt3ch added a commit that referenced this issue May 11, 2020
s0undt3ch added a commit to s0undt3ch/salt that referenced this issue May 11, 2020
dwoz pushed a commit that referenced this issue May 12, 2020
@s0undt3ch s0undt3ch linked a pull request May 13, 2020 that will close this issue
meaksh pushed a commit to meaksh/salt that referenced this issue Oct 20, 2020
* Update static requirements to include Py3.8 and Py3.9 (except windows)

Windows required package pywin32 doesn't state that it support any
python version above Py3.7

* Allow running the test suite against Py3.8 and Py3.9

* Fix deprecation warnings for imports from collections

DeprecationWarning: Using or importing the ABCs from `collections`
instead of from `collections.abc` is deprecated since Python 3.3, and in
3.9 it will stop working.

Therefore try to import the abstract base classes from `collections.abc`
before falling back to `collections`.

Signed-off-by: Benjamin Drung <[email protected]>

* Support distro.linux_distribution

Salt fails on Python 3.8:

```
======================================================================
ERROR: unit.grains.test_core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: unit.grains.test_core
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "tests/unit/grains/test_core.py", line 37, in <module>
    import salt.grains.core as core
  File "salt/grains/core.py", line 40, in <module>
    from platform import _supported_dists
ImportError: cannot import name '_supported_dists' from 'platform' (/usr/lib/python3.8/platform.py)
```

So only try to import `_supported_dists` from `platform` for Python <=
3.7. Otherwise rely on the external `distro` module to  not need any
special handling.

Addresses parts of saltstack#55835
Signed-off-by: Benjamin Drung <[email protected]>

* Fix RuntimeError: dictionary keys changed during iteration

The following unit tests fail on Python 3.8:

```
======================================================================
ERROR: test_state_config (unit.renderers.test_stateconf.StateConfigRendererTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 74, in test_state_config
    result = self._render_sls('''
  File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 66, in _render_sls
    return self._renderers['stateconf'](
  File "/<<PKGBUILDDIR>>/salt/renderers/stateconf.py", line 227, in render
    for k in six.iterkeys(tmplctx):  # iterate over a copy of keys
RuntimeError: dictionary keys changed during iteration

======================================================================
ERROR: test_apply_cloud_providers_config_extend (unit.test_config.ConfigTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1243, in test_apply_cloud_providers_config_extend
    salt.config.apply_cloud_providers_config(
  File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config
    for driver, details in six.iteritems(entries):
RuntimeError: dictionary keys changed during iteration

======================================================================
ERROR: test_apply_cloud_providers_config_extend_multiple (unit.test_config.ConfigTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1334, in test_apply_cloud_providers_config_extend_multiple
    self.assertEqual(ret, salt.config.apply_cloud_providers_config(overrides, defaults=DEFAULT))
  File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config
    for driver, details in six.iteritems(entries):
RuntimeError: dictionary keys changed during iteration

======================================================================
```

Replace the affected for loop of the first case by a dictionary
comprehension to construct the modified dictionary. For the remaining
cases, switch from `iteritems` to `iterkeys`, since the dictionary
values will be modified.

Signed-off-by: Benjamin Drung <[email protected]>

* Update PyTestSalt requirement(because we now bundle tornado)

* Run the full test suite on Arch under Py3

* Fix deprecation warnings for imports from collections

DeprecationWarning: Using or importing the ABCs from `collections`
instead of from `collections.abc` is deprecated since Python 3.3, and in
3.9 it will stop working.

Therefore try to import the abstract base classes from `collections.abc`
before falling back to `collections`.

Signed-off-by: Benjamin Drung <[email protected]>

* Replace deprecated inspect.formatargspec

Python 3.7 raises a deprecation warning:

salt/utils/decorators/signature.py:31: DeprecationWarning:
`formatargspec` is deprecated since Python 3.5. Use `signature` and the
`Signature` object directly

`inspect.formatargspec` is only used in
`salt.utils.decorators.signature.identical_signature_wrapper` which is
only used in `salt.utils.decorators.path` for decorating the `which` and
`which_bin` functions. The function `identical_signature_wrapper` can be
simply replaced by Python's `functools.wraps` which is available since
at least Python 2.7.

When inspecting those wrapped functions, the underlying function (stored
in the `__wrapped__` attribute) needs to be inspect instead.

fixes saltstack#50911
Signed-off-by: Benjamin Drung <[email protected]>

Co-authored-by: Pedro Algarvio <[email protected]>
Co-authored-by: Benjamin Drung <[email protected]>
meaksh pushed a commit to meaksh/salt that referenced this issue Apr 13, 2021
* Update static requirements to include Py3.8 and Py3.9 (except windows)

Windows required package pywin32 doesn't state that it support any
python version above Py3.7

* Allow running the test suite against Py3.8 and Py3.9

* Fix deprecation warnings for imports from collections

DeprecationWarning: Using or importing the ABCs from `collections`
instead of from `collections.abc` is deprecated since Python 3.3, and in
3.9 it will stop working.

Therefore try to import the abstract base classes from `collections.abc`
before falling back to `collections`.

Signed-off-by: Benjamin Drung <[email protected]>

* Support distro.linux_distribution

Salt fails on Python 3.8:

```
======================================================================
ERROR: unit.grains.test_core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: unit.grains.test_core
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "tests/unit/grains/test_core.py", line 37, in <module>
    import salt.grains.core as core
  File "salt/grains/core.py", line 40, in <module>
    from platform import _supported_dists
ImportError: cannot import name '_supported_dists' from 'platform' (/usr/lib/python3.8/platform.py)
```

So only try to import `_supported_dists` from `platform` for Python <=
3.7. Otherwise rely on the external `distro` module to  not need any
special handling.

Addresses parts of saltstack#55835
Signed-off-by: Benjamin Drung <[email protected]>

* Fix RuntimeError: dictionary keys changed during iteration

The following unit tests fail on Python 3.8:

```
======================================================================
ERROR: test_state_config (unit.renderers.test_stateconf.StateConfigRendererTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 74, in test_state_config
    result = self._render_sls('''
  File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 66, in _render_sls
    return self._renderers['stateconf'](
  File "/<<PKGBUILDDIR>>/salt/renderers/stateconf.py", line 227, in render
    for k in six.iterkeys(tmplctx):  # iterate over a copy of keys
RuntimeError: dictionary keys changed during iteration

======================================================================
ERROR: test_apply_cloud_providers_config_extend (unit.test_config.ConfigTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1243, in test_apply_cloud_providers_config_extend
    salt.config.apply_cloud_providers_config(
  File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config
    for driver, details in six.iteritems(entries):
RuntimeError: dictionary keys changed during iteration

======================================================================
ERROR: test_apply_cloud_providers_config_extend_multiple (unit.test_config.ConfigTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1334, in test_apply_cloud_providers_config_extend_multiple
    self.assertEqual(ret, salt.config.apply_cloud_providers_config(overrides, defaults=DEFAULT))
  File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config
    for driver, details in six.iteritems(entries):
RuntimeError: dictionary keys changed during iteration

======================================================================
```

Replace the affected for loop of the first case by a dictionary
comprehension to construct the modified dictionary. For the remaining
cases, switch from `iteritems` to `iterkeys`, since the dictionary
values will be modified.

Signed-off-by: Benjamin Drung <[email protected]>

* Update PyTestSalt requirement(because we now bundle tornado)

* Run the full test suite on Arch under Py3

* Fix deprecation warnings for imports from collections

DeprecationWarning: Using or importing the ABCs from `collections`
instead of from `collections.abc` is deprecated since Python 3.3, and in
3.9 it will stop working.

Therefore try to import the abstract base classes from `collections.abc`
before falling back to `collections`.

Signed-off-by: Benjamin Drung <[email protected]>

* Replace deprecated inspect.formatargspec

Python 3.7 raises a deprecation warning:

salt/utils/decorators/signature.py:31: DeprecationWarning:
`formatargspec` is deprecated since Python 3.5. Use `signature` and the
`Signature` object directly

`inspect.formatargspec` is only used in
`salt.utils.decorators.signature.identical_signature_wrapper` which is
only used in `salt.utils.decorators.path` for decorating the `which` and
`which_bin` functions. The function `identical_signature_wrapper` can be
simply replaced by Python's `functools.wraps` which is available since
at least Python 2.7.

When inspecting those wrapped functions, the underlying function (stored
in the `__wrapped__` attribute) needs to be inspect instead.

fixes saltstack#50911
Signed-off-by: Benjamin Drung <[email protected]>

Co-authored-by: Pedro Algarvio <[email protected]>
Co-authored-by: Benjamin Drung <[email protected]>
agraul pushed a commit to agraul/salt that referenced this issue Jun 25, 2021
* Update static requirements to include Py3.8 and Py3.9 (except windows)

Windows required package pywin32 doesn't state that it support any
python version above Py3.7

* Allow running the test suite against Py3.8 and Py3.9

* Fix deprecation warnings for imports from collections

DeprecationWarning: Using or importing the ABCs from `collections`
instead of from `collections.abc` is deprecated since Python 3.3, and in
3.9 it will stop working.

Therefore try to import the abstract base classes from `collections.abc`
before falling back to `collections`.

Signed-off-by: Benjamin Drung <[email protected]>

* Support distro.linux_distribution

Salt fails on Python 3.8:

```
======================================================================
ERROR: unit.grains.test_core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: unit.grains.test_core
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "tests/unit/grains/test_core.py", line 37, in <module>
    import salt.grains.core as core
  File "salt/grains/core.py", line 40, in <module>
    from platform import _supported_dists
ImportError: cannot import name '_supported_dists' from 'platform' (/usr/lib/python3.8/platform.py)
```

So only try to import `_supported_dists` from `platform` for Python <=
3.7. Otherwise rely on the external `distro` module to  not need any
special handling.

Addresses parts of saltstack#55835
Signed-off-by: Benjamin Drung <[email protected]>

* Fix RuntimeError: dictionary keys changed during iteration

The following unit tests fail on Python 3.8:

```
======================================================================
ERROR: test_state_config (unit.renderers.test_stateconf.StateConfigRendererTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 74, in test_state_config
    result = self._render_sls('''
  File "/<<PKGBUILDDIR>>/tests/unit/renderers/test_stateconf.py", line 66, in _render_sls
    return self._renderers['stateconf'](
  File "/<<PKGBUILDDIR>>/salt/renderers/stateconf.py", line 227, in render
    for k in six.iterkeys(tmplctx):  # iterate over a copy of keys
RuntimeError: dictionary keys changed during iteration

======================================================================
ERROR: test_apply_cloud_providers_config_extend (unit.test_config.ConfigTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1243, in test_apply_cloud_providers_config_extend
    salt.config.apply_cloud_providers_config(
  File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config
    for driver, details in six.iteritems(entries):
RuntimeError: dictionary keys changed during iteration

======================================================================
ERROR: test_apply_cloud_providers_config_extend_multiple (unit.test_config.ConfigTestCase)
[CPU:0.0%|MEM:56.6%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_config.py", line 1334, in test_apply_cloud_providers_config_extend_multiple
    self.assertEqual(ret, salt.config.apply_cloud_providers_config(overrides, defaults=DEFAULT))
  File "/<<PKGBUILDDIR>>/salt/config/__init__.py", line 3196, in apply_cloud_providers_config
    for driver, details in six.iteritems(entries):
RuntimeError: dictionary keys changed during iteration

======================================================================
```

Replace the affected for loop of the first case by a dictionary
comprehension to construct the modified dictionary. For the remaining
cases, switch from `iteritems` to `iterkeys`, since the dictionary
values will be modified.

Signed-off-by: Benjamin Drung <[email protected]>

* Update PyTestSalt requirement(because we now bundle tornado)

* Run the full test suite on Arch under Py3

* Fix deprecation warnings for imports from collections

DeprecationWarning: Using or importing the ABCs from `collections`
instead of from `collections.abc` is deprecated since Python 3.3, and in
3.9 it will stop working.

Therefore try to import the abstract base classes from `collections.abc`
before falling back to `collections`.

Signed-off-by: Benjamin Drung <[email protected]>

* Replace deprecated inspect.formatargspec

Python 3.7 raises a deprecation warning:

salt/utils/decorators/signature.py:31: DeprecationWarning:
`formatargspec` is deprecated since Python 3.5. Use `signature` and the
`Signature` object directly

`inspect.formatargspec` is only used in
`salt.utils.decorators.signature.identical_signature_wrapper` which is
only used in `salt.utils.decorators.path` for decorating the `which` and
`which_bin` functions. The function `identical_signature_wrapper` can be
simply replaced by Python's `functools.wraps` which is available since
at least Python 2.7.

When inspecting those wrapped functions, the underlying function (stored
in the `__wrapped__` attribute) needs to be inspect instead.

fixes saltstack#50911
Signed-off-by: Benjamin Drung <[email protected]>

Co-authored-by: Pedro Algarvio <[email protected]>
Co-authored-by: Benjamin Drung <[email protected]>
andzn pushed a commit to andzn/salt that referenced this issue Nov 15, 2021
Salt fails on Python 3.8:

```
======================================================================
ERROR: unit.grains.test_core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: unit.grains.test_core
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "tests/unit/grains/test_core.py", line 37, in <module>
    import salt.grains.core as core
  File "salt/grains/core.py", line 40, in <module>
    from platform import _supported_dists
ImportError: cannot import name '_supported_dists' from 'platform' (/usr/lib/python3.8/platform.py)
```

So only try to import `_supported_dists` from `platform` for Python <=
3.7. Otherwise rely on the external `distro` module to  not need any
special handling.

Addresses parts of saltstack#55835
Signed-off-by: Benjamin Drung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Epic ZRelease-Sodium retired label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants