Windows encoding of __init__.py breaks setup with certain locales
envgap__AzureAD__azure-activedirectory-library-for-python-89
01 / FAILURE SIGNATURE
As reported upstream
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
b1d7644c1c234915a51e7b4b123a0b65d438b7f7- Manifest
setup.py- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
AzureAD/azure-activedirectory-library-for-python #89 · read the original issue
The ```setup.py``` script parses the version number from the ```adal/__init__.py```. This can fail with certain locales on Linux when Python3 is being used:
```bash
glaubitz@suse-laptop:~/upstream/azure-activedirectory-library-for-python> LANG=C python3 setup.py build
Traceback (most recent call last):
File "setup.py", line 35, in <module>
open('adal/__init__.py').read()).group(1)
File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
glaubitz@suse-laptop:~/upstream/azure-activedirectory-library-for-python>
```
This is because of the Windows encoding of ```__init__.py``` contains a byte-order mark at the beginning of the file:
```
<U+FEFF>#------------------------------------------------------------------------------
```
simply converting ```__init__.py``` to standard Unix format fixes the problem:
```bash
glaubitz@suse-laptop:~/upstream/azure-activedirectory-library-for-python> dos2unix adal/__init__.py
dos2unix: converting file adal/__init__.py to Unix format...
glaubitz@suse-laptop:~/upstream/azure-activedirectory-library-for-python> LANG=C python3 setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/adal
copying adal/constants.py -> build/lib/adal
copying adal/adal_error.py -> build/lib/adal
copying adal/cache_driver.py -> build/lib/adal
copying adal/mex.py -> build/lib/adal
copying adal/xmlutil.py -> build/lib/adal
copying adal/authority.py -> build/lib/adal
copying adal/authentication_context.py -> build/lib/adal
copying adal/wstrust_response.py -> build/lib/adal
copying adal/self_signed_jwt.py -> build/lib/adal
copying adal/authentication_parameters.py -> build/lib/adal
copying adal/util.py -> build/lib/adal
copying adal/argument.py -> build/lib/adal
copying adal/user_realm.py -> build/lib/adal
copying adal/oauth2_client.py -> build/lib/adal
copying adal/token_cache.py -> build/lib/adal
copying adal/log.py -> build/lib/adal
copying adal/wstrust_request.py -> build/lib/adal
copying adal/token_request.py -> build/lib/adal
copying adal/__init__.py -> build/lib/adal
copying adal/code_request.py -> build/lib/adal
glaubitz@suse-laptop:~/upstream/azure-activedirectory-library-for-python>
```
This problem also affects the building of RPM packages. In fact, I stumbled over this issue when trying to build the python3 RPM package for ADAL.
Please consider plain UTF-8 for the source code encoding.04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]