Skip to content

Commit

Permalink
Fix Salt warnings and testuite for Python 3.11 (#635)
Browse files Browse the repository at this point in the history
* Switch to `FullArgSpec` since Py 3.11 no longer has `ArgSpec`, deprecated since Py 3.0

Signed-off-by: Pedro Algarvio <[email protected]>

* Backport `locale.getdefaultlocale()` into Salt. It's getting removed in Py 3.13

Signed-off-by: Pedro Algarvio <[email protected]>

* Stop using the deprecated `pipes` module

Signed-off-by: Pedro Algarvio <[email protected]>

* Stop using the deprecated `cgi` module.

Signed-off-by: Pedro Algarvio <[email protected]>

* Add `__getstate__` to blacklisted methods, present in Py 3.11

Signed-off-by: Pedro Algarvio <[email protected]>

* Fix test_state test

* Use proper keys since Python's base64 in Py3.11 is more picky

```
❯ artifacts/salt/bin/python3
Python 3.10.11 (main, May  5 2023, 02:31:54) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> base64.b64decode("AAAAB3NzaC1kcQ9J5bYTEyZ==", validate=True)
b'\x00\x00\x00\x07ssh-dq\x0fI\xe5\xb6\x13\x13&'
```
```
$ artifacts/salt/bin/python3
Python 3.11.3 (main, May  5 2023, 02:31:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> base64.b64decode("AAAAB3NzaC1kcQ9J5bYTEyZ==", validate=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/testing/artifacts/salt/lib/python3.11/base64.py", line 88, in b64decode
    return binascii.a2b_base64(s, strict_mode=validate)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
binascii.Error: Excess data after padding
```

Signed-off-by: Pedro Algarvio <[email protected]>

---------

Signed-off-by: Pedro Algarvio <[email protected]>
Co-authored-by: Pedro Algarvio <[email protected]>
Co-authored-by: Marek Czernek <[email protected]>
  • Loading branch information
3 people authored and meaksh committed Oct 29, 2024
1 parent 1834acc commit c8a8ec3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/pytests/unit/modules/state/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def test_show_states_missing_sls():
chunks_mock = MagicMock(side_effect=[msg])
mock = MagicMock(side_effect=["A", None])
with patch.object(state, "_check_queue", mock), patch(
"salt.state.HighState.compile_low_chunks", chunks_mock
"salt.modules.state.salt.state.HighState.compile_low_chunks", chunks_mock
):
assert state.show_low_sls("foo") == "A"
assert state.show_states("foo") == [msg[0]]
Expand Down

0 comments on commit c8a8ec3

Please sign in to comment.