[osgeo4w-dev] [osgeo4w] #682: MSI and EXE installers: different Python locale settings leads to issues with the Python console script editor

OSGeo4W trac_osgeo4w at osgeo.org
Tue Jun 22 08:58:15 PDT 2021


#682: MSI and EXE installers: different Python locale settings leads to issues
with the Python console script editor
------------------------+---------------------------
Reporter:  andreaerdna  |      Owner:  osgeo4w-dev@…
    Type:  defect       |     Status:  new
Priority:  major        |  Component:  Package
 Version:               |   Keywords:
------------------------+---------------------------
 With the old OSGeo4W repository EXE installer (QGIS 3.18.1):


 {{{
 import sys
 bool(sys.flags.utf8_mode)
 True

 import locale
 locale.getpreferredencoding(False)
 'UTF-8'
 }}}


 while with the new OSGeo4W repository MSI installer (QGIS 3.18.1):


 {{{
 import sys
 bool(sys.flags.utf8_mode)
 False

 import locale
 locale.getpreferredencoding(False)
 'cp1252'
 }}}

 With the new MSI installer, this leads to issues with the Python console
 script editor if the script contains non cp1252 encoded characters, while
 there is no issue with the old EXE installer, as reported on GitHub issue
 tracker https://github.com/qgis/QGIS/issues/43834


 **How to Reproduce**

 Enter
 {{{
 print('áéŐŰÍ')
 }}}
 in the Python script editor window and run the script.

 The script will execute without issue using QGIS from the old repository
 EXE installer, while it will generate the following error using QGIS from
 the new repository MSI installer:

 {{{
 Traceback (most recent call last):
   File "F:\QGIS\SOURCE~1\qgis\apps\Python39\lib\code.py", line 90, in
 runcode
     exec(code, self.locals)
   File "<input>", line 1, in <module>
   File "F:\QGIS\SOURCE~1\qgis\apps\Python39\lib\encodings\cp1252.py", line
 23, in decode
     return codecs.charmap_decode(input,self.errors,decoding_table)[0]
 UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 12:
 character maps to <undefined>
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/osgeo4w/ticket/682>
OSGeo4W <http://trac.osgeo.org/osgeo4w>
OSGeo4W is the Windows installer and package environment for the OSGeo stack.


More information about the osgeo4w-dev mailing list