azure_preview_modules
azure_preview_modules copied to clipboard
CI error: UnicodeEncodeError: 'ascii' codec can't encode character u'\\u2018' in position 596
This issue I've seen multiple times in both master
branch CI tests and while working on #358.
Examples:
- https://travis-ci.org/Azure/azure_preview_modules/jobs/648225075#L716
- https://travis-ci.org/Azure/azure_preview_modules/jobs/648225084#L1026
- https://travis-ci.org/Azure/azure_preview_modules/jobs/648311452#L1268
- https://travis-ci.org/Azure/azure_preview_modules/jobs/648311454#L798
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).
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'))
@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!