[issue45232] ascii codec is used by default when LANG is not set

2021-09-17 Thread Olivier Delhomme

New submission from Olivier Delhomme :

$ python3 --version
Python 3.6.4

Setting LANG to en_US.UTF8 works like a charm

$ export LANG=en_US.UTF8   
$ python3
Python 3.6.4 (default, Jan 11 2018, 16:45:55) 
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> machaine='help me if you can'   
>>> 
>>>  
>>> print('{}'.format(machaine))
>>> 
>>>  
help me if you can


Unsetting LANG shell variable fails the program:

$ unset LANG
$ python3
Python 3.6.4 (default, Jan 11 2018, 16:45:55) 
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> machaine='help me if you can'
  File "", line 0

^
SyntaxError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not 
in range(128)


Setting LANG inside the program does not change this behavior:

$ unset LANG
$ python3
Python 3.6.4 (default, Jan 11 2018, 16:45:55) 
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['LANG'] = 'en_US.UTF8'
>>> machaine='help me if you can'
  File "", line 0

^
SyntaxError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not 
in range(128)


Is this an expected behavior ? How can I force an utf8 codec ?

--
components: Interpreter Core
messages: 402046
nosy: od-cea
priority: normal
severity: normal
status: open
title: ascii codec is used by default when LANG is not set
type: behavior
versions: Python 3.6

___
Python tracker 
<https://bugs.python.org/issue45232>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45232] ascii codec is used by default when LANG is not set

2021-09-17 Thread Olivier Delhomme

Olivier Delhomme  added the comment:

Hi Marc-Andre,

Please note that setting PYTHONUTF8 with "export PYTHONUTF8=1":

* Is external to the program and user dependent
* It does not seems to work on my use case:

  $ unset LANG
  $ export PYTHONUTF8=1
  $ python3 
  Python 3.6.4 (default, Jan 11 2018, 16:45:55) 
  [GCC 4.8.5] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> machaine='help me if you can'
 File "", line 0

   ^
   SyntaxError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal 
not in range(128)


Regards,

Olivier.

--

___
Python tracker 
<https://bugs.python.org/issue45232>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45232] ascii codec is used by default when LANG is not set

2021-09-17 Thread Olivier Delhomme

Olivier Delhomme  added the comment:

>> Hi Marc-Andre,
>>
>> Please note that setting PYTHONUTF8 with "export PYTHONUTF8=1":
>>
>> * Is external to the program and user dependent
>> * It does not seems to work on my use case:
>>
>>$ unset LANG
>>$ export PYTHONUTF8=1
>>$ python3
>>Python 3.6.4 (default, Jan 11 2018, 16:45:55)
>>[GCC 4.8.5] on linux
>>Type "help", "copyright", "credits" or "license" for more information.
>>>>> machaine='help me if you can'
>>   File "", line 0
>>  
>> ^
>> SyntaxError: 'ascii' codec can't decode byte 0xc3 in position 10: 
>> ordinal not in range(128)
> 
> UTF-8 mode is only supported in Python 3.7 and later:
> 
> https://docs.python.org/3/whatsnew/3.7.html#whatsnew37-pep540

Oh. Thanks.

$ unset LANG
$ export PYTHONUTF8=1
$ python3
Python 3.7.5 (default, Dec 24 2019, 08:52:13)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> machaine='help me if you can'
 >>>

 From the code point of view:

$ unset LANG
$ unset PYTHONUTF8
$ python3
Python 3.7.5 (default, Dec 24 2019, 08:52:13)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import os
 >>> os.environ['PYTHONUTF8'] = '1'
 >>> machaine='help me if you can'
 >>>

Even better:

$ unset LANG
$ unset PYTHONUTF8
$ python3
Python 3.7.5 (default, Dec 24 2019, 08:52:13)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> machaine='help me if you can'
 >>>

Works as expected. Thank you very much. You can close this bug report.

Regards,

Olivier.

--

___
Python tracker 
<https://bugs.python.org/issue45232>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com