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

psrp - fix unicode handling in Python 2 #47461

Merged
merged 2 commits into from
Oct 23, 2018
Merged

Conversation

jborean93
Copy link
Contributor

SUMMARY

Further fix of #46998. This first checks if the type is a GenericComplexObject without a ToString entry and then uses to_text after that. This test also returns the output as a byte string which is what is expected for exec_command in the connection plugin.

Lastly adds some custom psrp only tests to test these situations that are unique for PSRP.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

psrp

ANSIBLE VERSION
devel

@ansibot
Copy link
Contributor

ansibot commented Oct 23, 2018

Hi @jborean93, thank you for submitting this pull-request!

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 23, 2018
@jborean93 jborean93 force-pushed the psrp-utf8 branch 5 times, most recently from ca3962f to 88e894a Compare October 23, 2018 02:14
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 23, 2018
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 23, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 23, 2018
# Not all pipeline outputs are a string or contain a __str__ value,
# we will create our own output based on the properties of the
# complex object if that is the case.
if isinstance(output, GenericComplexObject) and output.to_string is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If .to_string() exists, do we have to call that explicitly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also, is this the way to check for to_string? I don't know the API so I don't know if it really creates the attribute but sets it to None or if it omits the attribute altogether.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_string always exists, it's just set to None by default https://github.com/jborean93/pypsrp/blob/master/pypsrp/complex_objects.py#L109. It will get populated if the <ToString></ToString> element is populated on the XML being deserialized from the server. In the first case, to_string is None so we need to manually build the string representation from the properties otherwise we just call str() which works for a GenericComplexObject as well as any other non generic ComplexObjects.

@jborean93 jborean93 merged commit f28b7c7 into ansible:devel Oct 23, 2018
@jborean93 jborean93 deleted the psrp-utf8 branch October 23, 2018 19:37
jborean93 added a commit to jborean93/ansible that referenced this pull request Oct 23, 2018
* psrp - fix unicode handling in Python 2

* skip psrp become test when on Server 2008

(cherry picked from commit f28b7c7)
@jborean93
Copy link
Contributor Author

Backport PR stable-2.7 #47530

abadger pushed a commit that referenced this pull request Oct 24, 2018
* psrp - fix unicode handling in Python 2

* skip psrp become test when on Server 2008

(cherry picked from commit f28b7c7)
@mkrizek mkrizek removed needs_triage Needs a first human triage before being processed. labels Oct 25, 2018
Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
* psrp - fix unicode handling in Python 2

* skip psrp become test when on Server 2008
@dagwieers dagwieers added the windows Windows community label Jan 31, 2019
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants