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

convert xml_string to utf-8 instead of ascii #44

Merged
merged 2 commits into from
Sep 12, 2016

Conversation

systemheld
Copy link
Contributor

ElementTree.fromstring() will handle only str(), but xml_string is an unicode() so it gets automatically casted to 'ascii' - but 'utf-8' is better for so many reasons. fixes jssimporter/JSSImporter#61

@sheagcraig
Copy link
Collaborator

@ocoda Thanks! I missed that possibility when I added this in.

I attempted at one point to force everything to unicode on the way in, but I failed when I discovered that ElementTree only took ASCII.

Can you add in a brief description to the docstring explaining that it assumes UTF-8 as the encoding? I mean, that's what the JSS spits out, so I'm not sure how it would show up as anything else. Maybe not needed. Any thoughts?

@systemheld
Copy link
Contributor Author

Well, I'm not sure if I get your right. The problem is, that ElementTree expects a str() - which can be utf-8 encoded. That is not the same as a unicode() element, which xml_string is. So xml_string gets automatically casted from unicode() to str() - by default assuming that unicode() only contains ascii characters. Python 2 is really weird here.

I did a small precision to the docstring. Not sure what more to say.

@sheagcraig
Copy link
Collaborator

I get a little tripped up on this, but I think what you're saying makes sense. Let me run the testing suite on this; and then we'll merge it in.

@sheagcraig
Copy link
Collaborator

This is staged in the testing branch, to be merged into master pending some validation.

I don't have a JSS. If you could verify that the testing tip works, I know you're good for it. Otherwise, I have to get access to a JSS and concoct something with umlauts to test with.

@systemheld
Copy link
Contributor Author

I've run the jss_test.py but it does simply nothing. Reading some of the code, it seems that this is expecting some test policies and other elements to be present, but does not state how they should look like. Do you have any documentation about this?

BTW: in the comment you state that some defaults must be set for this to work. You state the domain in com.github.sheagcraig.python-jss but it is com.github.sheagcraig.python-jss.test-server. You should update this, too! :-)

@sheagcraig sheagcraig merged commit 21263bf into jssimporter:master Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSSImporter fails with umlauts in self_service_description
2 participants