cflavio / yorg

Yorg (Yorg's an Open Racing Game) is a free open source racing game developed by Ya2 using Panda3D for Windows, OSX and Linux.
Other
177 stars 33 forks source link

Locale issue in menu/mainpage.py::set_news on Linux (UTF-8 parsed as ascii) #6

Closed akien-mga closed 7 years ago

akien-mga commented 7 years ago

My system locale on Linux is as follows:

$ locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

When running the game with python2 main.py, the menu fails loading and the application terminates:

:ya2: 19:24:11 entering Menu state
Traceback (most recent call last):
  File "main.py", line 29, in <module>
    Yorg()
  File "/home/akien/tmp/yorg-src/yorg/yorg/yorg.py", line 79, in __init__
    Game.__init__(self, init_lst, conf)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/game.py", line 41, in __init__
    GameBase.__init__(self, init_lst, cfg)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/game.py", line 31, in __init__
    self.logic.on_start()
  File "/home/akien/tmp/yorg-src/yorg/yorg/logic.py", line 29, in on_start
    self.mdt.fsm.demand('Menu')
  File "/usr/share/panda3d/direct/fsm/FSM.py", line 278, in demand
    if not self.request(request, *args):
  File "/usr/share/panda3d/direct/fsm/FSM.py", line 321, in request
    self.__setState(*result)
  File "/usr/share/panda3d/direct/fsm/FSM.py", line 456, in __setState
    self.__callEnterFunc(self.newState, *args)
  File "/usr/share/panda3d/direct/fsm/FSM.py", line 492, in __callEnterFunc
    func(*args)
  File "/home/akien/tmp/yorg-src/yorg/yorg/fsm.py", line 56, in enterMenu
    self.__menu = YorgMenu(menu_props)
  File "/home/akien/tmp/yorg-src/yorg/menu/menu.py", line 60, in __init__
    GameObject.__init__(self, init_lst)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/gameobject.py", line 121, in __init__
    GODirector(self, init_lst, callback)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/gameobject.py", line 89, in __init__
    self.__process_lst(tgt_obj, idx)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/gameobject.py", line 98, in __process_lst
    setattr(obj, comp_info[0], comp_info[1](*comp_info[2]))
  File "/home/akien/tmp/yorg-src/yorg/menu/menu.py", line 49, in __init__
    self.menu.logic.push_page(YorgMainPage(self.menu, mainpage_props))
  File "/home/akien/tmp/yorg-src/yorg/menu/mainpage.py", line 177, in __init__
    GameObject.__init__(self, init_lst)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/gameobject.py", line 121, in __init__
    GODirector(self, init_lst, callback)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/gameobject.py", line 89, in __init__
    self.__process_lst(tgt_obj, idx)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/gameobject.py", line 98, in __process_lst
    setattr(obj, comp_info[0], comp_info[1](*comp_info[2]))
  File "/home/akien/tmp/yorg-src/yorg/menu/mainpage.py", line 52, in __init__
    MainPageGui.__init__(self, mdt, menu)
  File "/home/akien/tmp/yorg-src/yorg/yyagl/engine/gui/page.py", line 23, in __init__
    self.bld_page()
  File "/home/akien/tmp/yorg-src/yorg/menu/mainpage.py", line 111, in bld_page
    self.set_news()
  File "/home/akien/tmp/yorg-src/yorg/menu/mainpage.py", line 158, in set_news
    for i in range(5)]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Forcing any value for LC_ALL (e.g. "C", "en" or "fr") works around the issue, though a warning is shown:

$ LC_ALL=C python main.py  
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
AL lib: (WW) ALCjackBackendFactory_init: jack_client_open() failed, 0x11
AL lib: (WW) alc_initconfig: Failed to initialize backend "jack"
:ya2: 19:26:54 version: source
sh: warning: setlocale: LC_ALL: cannot change locale (fr_FR.UTF-8)

Trying to force LC_ALL=fr_FR.UTF-8 reproduces the bug.


System info:

:ya2: 19:22:32 version: source
:ya2: 19:22:32 operative system: Linux 4.9.35-desktop-1.mga6 #1 SMP Thu Jun 29 19:27:27 UTC 2017
:ya2: 19:22:32 architecture: ('64bit', 'ELF')
:ya2: 19:22:32 machine: x86_64
:ya2: 19:22:32 platform: Linux-4.9.35-desktop-1.mga6-x86_64-with-mageia-6-Cauldron
:ya2: 19:22:32 processor: x86_64
:ya2: 19:22:32 cores: 4
:ya2: 19:22:32 panda version: 1.9.4 
:ya2: 19:22:32 bullet version: 286
:ya2: 19:22:32 appdata: /home/akien
:ya2: 19:22:32 NVIDIA Corporation
:ya2: 19:22:32 GeForce GTX 670MX/PCIe/SSE2
:ya2: 19:22:32 shader: 4.50
:ya2: 19:22:32 4.5.0 NVIDIA 375.66
:ya2: 19:22:32 driver version: 4.5
:ya2: 19:22:32 fullscreen: False
:ya2: 19:22:32 resolution: 1280x720