if there is binary string (like '\x00\x46 \xFE') in the source file, we ...

...can't directly decode with enc, the safest way is still to read from source string.

you can test it on this file:
https://github.com/django/django/blob/master/tests/backends/tests.py#L340

otherwise, this would cause pysonar try python3 because it failed to use python2, which later cause program die because it is not a python3 program. without this patch, you need disable python3 in order to proceed on some projects