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

Change StringIO and BytesIO imports #49555

Merged
merged 2 commits into from Sep 18, 2018

Conversation

Projects
None yet
4 participants
@bergmannf
Copy link
Contributor

commented Sep 7, 2018

Call StringIO class directly instead of using the python2 module.class way.

Also use the correct BytesIO instead of StringIO in python3.

What does this PR do?

Fix AttributeError in the hashutil module.

What issues does this PR fix or reference?

https://bugzilla.suse.com/show_bug.cgi?id=1107311

Previous Behavior

base64_encodefile would throw an AttributeError.

New Behavior

base64_encodefile will no longer throw an error.

Tests written?

No

But to test it I used:

/srv/salt/b64/init.sls:

/tmp/hello:
  file.managed:
    - create: True
    - contents:
      - Hello World

/srv/salt/b64/hash.sls:

/tmp/hashed_hello:
  file.managed:
    - contents: {{ salt.hashutil.base64_encodefile('/tmp/hello') }}

/srv/salt/b64/unhash.sls:

/tmp/unhashed_hello:
  module.run:
    - name: hashutil.base64_decodefile
    - instr: {{ salt.file.read('/tmp/hashed_hello') }}
    - outfile: /tmp/unhashed_hello

The then just run them in the right order:

salt '*' state.apply b64.init
salt '*' state.apply b64.hash
salt '*' state.apply b64.unhash

Please review Salt's Contributing Guide for best practices.

Change StringIO import in python2 to import the class.
Instead of using StringIO in python3, use the correct BytesIO class instead.
@dwoz

dwoz approved these changes Sep 17, 2018

@rallytime rallytime merged commit 2cb319d into saltstack:develop Sep 18, 2018

7 of 11 checks passed

continuous-integration/jenkins/pr-merge This commit cannot be built
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has failed
Details
jenkins/pr/py2-windows-2016 The py2-windows-2016 job has failed
Details
jenkins/pr/py3-windows-2016 The py3-windows-2016 job has failed
Details
WIP ready for review
Details
codeclimate All good!
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details

rallytime added a commit that referenced this pull request Sep 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.