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

CI error: UnicodeEncodeError: 'ascii' codec can't encode character u'\\u2018' in position 596 #359

Open
internetionals opened this issue Feb 10, 2020 · 2 comments

Comments

@internetionals
Copy link

This issue I've seen multiple times in both master branch CI tests and while working on #358.

Examples:

Excerpt:

"/home/travis/virtualenv/python2.7.15/lib/python2.7/site-packages/msrestazure/azure_exceptions.py", line 89, in __str__
   error_str += "Message: {}".format(self._message)
UnicodeEncodeError: 'ascii' codec can't encode character u'\\u2018' in position 596: ordinal not in range(128)

When looking at this error in the msrestazure python module we see it originates inside the CloudErrorData class. So this leads to me assuming that the Azure API is returning a unicode quote in it's error message.

The problem is that this error message is being encoded as 'ascii'. This is probably due to the environment the tests is being run in (when no special locale or language variables have been set then python will fall back to ascii encoded output).

@internetionals
Copy link
Author

I did an experiment in #358 to see if setting PYTHONIOENCODING=utf-8 would help, but that didn't appear to change anything.

I'm still a bit mystified why python is choosing ascii encoding in this case, since setting the above variable appears to fix all relevant encodings, but that is probably due to my limited python experience.

I think the actual fix is to be made in the Azure/msrestazure-for-python project. Probably something along the lines of changing:

 89         error_str += "\nMessage: {}".format(self._message)

To:

 89         error_str += "\nMessage: {}".format(self._message.encode('ascii', 'replace'))

@Fred-sun
Copy link
Collaborator

@internetionals Thank you very much for your interest in Ansible. This repo is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/azure
Please re-submit this Issue in the above repository and closed this. Thank you very much!

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

No branches or pull requests

2 participants