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

[BUG] yumpkg is broken for Python<3.8 #67151

Open
hurzhurz opened this issue Jan 15, 2025 · 0 comments
Open

[BUG] yumpkg is broken for Python<3.8 #67151

hurzhurz opened this issue Jan 15, 2025 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@hurzhurz
Copy link
Contributor

hurzhurz commented Jan 15, 2025

Description
Since 3006.9 yumpkg does not work anymore on systems with Python versions below 3.8.
This is relevant for example when using salt-ssh.

The cause is simply the usage of the assignment/named expression in this fix: 00f6d42

This is the result when trying to use the pkg module with salt-ssh on a system with Python 3.6.8:

# salt-ssh xyz pkg.list_pkgs
xyz:
    ----------
    retcode:
        255
    stderr:
        'pkg.list_pkgs' is not available.
    stdout:
    [ERROR   ] Failed to import module kernelpkg_linux_yum, this is due most likely to a syntax error:
    Traceback (most recent call last):
      File "/var/tmp/.root_78a1bd_salt/pyall/salt/loader/lazy.py", line 785, in _load_module
        mod = self.run(spec.loader.load_module)
      File "/var/tmp/.root_78a1bd_salt/pyall/salt/loader/lazy.py", line 1245, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/var/tmp/.root_78a1bd_salt/py3/contextvars/__init__.py", line 38, in run
        return callable(*args, **kwargs)
      File "/var/tmp/.root_78a1bd_salt/pyall/salt/loader/lazy.py", line 1260, in _run_as
        ret = _func_or_method(*args, **kwargs)
      File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
      File "<frozen importlib._bootstrap_external>", line 823, in load_module
      File "<frozen importlib._bootstrap_external>", line 682, in load_module
      File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
      File "<frozen importlib._bootstrap>", line 684, in _load
      File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 678, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/var/tmp/.root_78a1bd_salt/pyall/salt/modules/kernelpkg_linux_yum.py", line 8, in <module>
        import salt.modules.yumpkg
      File "/var/tmp/.root_78a1bd_salt/pyall/salt/modules/yumpkg.py", line 1427
        if (version := kwargs.get("version")) is not None:
                    ^
    SyntaxError: invalid syntax

This is my proposed fix to get it working again:

-    if (version := kwargs.get("version")) is not None:
-        kwargs["version"] = str(version)
+    if kwargs.get("version") is not None:
+        kwargs["version"] = str(kwargs["version"])

Versions Report

salt --versions-report
Salt Version:
          Salt: 3006.9

Python Version:
        Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
  cryptography: 42.0.5
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.17.0
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 22.04.5 jammy
        locale: utf-8
       machine: x86_64
       release: 5.15.0-130-generic
        system: Linux
       version: Ubuntu 22.04.5 jammy
@hurzhurz hurzhurz added Bug broken, incorrect, or confusing behavior needs-triage labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant