-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Conversation
Hi @jborean93, thank you for submitting this pull-request! |
ca3962f
to
88e894a
Compare
# 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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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
.
* psrp - fix unicode handling in Python 2 * skip psrp become test when on Server 2008 (cherry picked from commit f28b7c7)
Backport PR stable-2.7 #47530 |
* psrp - fix unicode handling in Python 2 * skip psrp become test when on Server 2008 (cherry picked from commit f28b7c7)
* psrp - fix unicode handling in Python 2 * skip psrp become test when on Server 2008
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
COMPONENT NAME
psrp
ANSIBLE VERSION