Use AWS_CLI_FILE_ENCODING environment variable value as encoding, if it's not set use locale.getpreferredencoding() to find the preferred encoding.
(*args, **kwargs)
| 182 | |
| 183 | |
| 184 | def getpreferredencoding(*args, **kwargs): |
| 185 | """Use AWS_CLI_FILE_ENCODING environment variable value as encoding, |
| 186 | if it's not set use locale.getpreferredencoding() |
| 187 | to find the preferred encoding. |
| 188 | """ |
| 189 | if 'AWS_CLI_FILE_ENCODING' in os.environ: |
| 190 | return os.environ['AWS_CLI_FILE_ENCODING'] |
| 191 | # in Python 3.8 PyConfig API has been changed but pyInstaller only |
| 192 | # partially supports these changes, one thing it doesn't support is |
| 193 | # auto-conversion POSIX locale to UTF-8 which is part of PEP-540 |
| 194 | # so we have to implement this conversion on our side |
| 195 | lc_type = locale.setlocale(locale.LC_CTYPE) |
| 196 | if lc_type in ('C', 'POSIX'): |
| 197 | return 'UTF-8' |
| 198 | return locale.getpreferredencoding(*args, **kwargs) |
| 199 | |
| 200 | |
| 201 | def compat_open(filename, mode='r', encoding=None, access_permissions=None): |
no outgoing calls