salt icon indicating copy to clipboard operation
salt copied to clipboard

[BUG] Remove base64.encodestring/decodestring, since they're removed in Python 3.9

Open waynew opened this issue 6 years ago • 3 comments

Description

base64.encodestring() and base64.decodestring(), aliases deprecated since Python 3.1, have been removed: use base64.encodebytes() and base64.decodebytes() instead. (Contributed by Victor Stinner in bpo-39351.)

  • https://docs.python.org/3.9/whatsnew/3.9.html#removed

This should be a pretty minor change, it also doesn't look like either calls are used in essential common places within Salt, though there will be several locations that would completely fail.

waynew avatar Aug 19 '20 16:08 waynew

There are below call sites. Does salt support python 2 to ensure the PR needs compatibility? I can see places where ABC is imported from collections.abc module being Python 3 only. I read the FAQ at https://docs.saltstack.com/en/latest/topics/development/faq-py2-deprecation.html but I am slightly confused and wanted to confirm on the same

rg -t py ' base64\.(encode|decode)string'
tests/unit/modules/test_k8s.py
74:        data = {"testsecret": base64.encodestring("teststring")}

salt/modules/nexus.py
105:            base64.encodestring("{0}:{1}".format(username, password)).replace("\n", "")
184:            base64.encodestring("{0}:{1}".format(username, password)).replace("\n", "")
248:            base64.encodestring("{0}:{1}".format(username, password)).replace("\n", "")
311:            base64.encodestring("{0}:{1}".format(username, password)).replace("\n", "")
382:            base64.encodestring("{0}:{1}".format(username, password)).replace("\n", "")

salt/cloud/clouds/aliyun.py
767:    signature = base64.encodestring(h.digest()).strip()

salt/utils/hashutils.py
62:            base64.encodestring(salt.utils.stringutils.to_bytes(instr)),
84:        decoded = base64.decodestring(bvalue)

tirkarthi avatar Sep 15 '20 12:09 tirkarthi

+1 for this. The nexus module is completely non-functional in py3. Same issue and fix as #56660

tannerwilliams avatar Mar 01 '21 23:03 tannerwilliams

Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.

Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.

If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.

dwoz avatar Oct 15 '26 23:10 dwoz