! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Float parsing error causes configuration dialog fails to load
Status:
RESOLVED: FIXED
Product:
Xfce4-screensaver
Component:
General

Comments

Description Gusti Syahputera 2019-12-22 13:14:11 CET
Created attachment 9326 
Patch

Steps to reproduce:
0. Use a system that does not use dot (.) as decimal separator.
1. Open the screensaver preferences (`xfce4-screensaver-preference`).
2. Select any screensaver within the "Theme" listbox.
3. Click the "Configure screensaver" button which will open the configuration dialog for the particular screensaver.
4. Change any numerical parameter (e.g. the frame rate).
5. Close the configuration dialog.
6. On the main screensaver preferences dialog, click the "Configure screensaver" button once again.

Results:
The configuration dialog (`xfce4-screensaver-configure`) is supposed to be shown just like the first attempt. However, it does not. Instead, it terminates when it attempts to parse a double-type parameter value given by the `xfconf-query` program, which happens to respects the system's locale preferences:

[stdout of xfce4-screensaver-configure]
Traceback (most recent call last):
  File "/usr/bin/xfce4-screensaver-configure", line 756, in <module>
    configure(obj.to_dict())
  File "/usr/bin/xfce4-screensaver-configure", line 678, in configure
    win = ConfigurationWindow(parsed)
  File "/usr/bin/xfce4-screensaver-configure", line 395, in __init__
    widget = self.get_option_widget(opt)
  File "/usr/bin/xfce4-screensaver-configure", line 488, in get_option_widget
    value = self.get_double(opt["id"], opt["default"])
  File "/usr/bin/xfce4-screensaver-configure", line 518, in get_double
    value = self.xfconf_channel.get_double(option_id, default)
  File "/usr/bin/xfce4-screensaver-configure", line 83, in get_double
    return float(self._get_property(prop, default))
ValueError: could not convert string to float: '8000,000000'
[end]

Possible solution:
Instead of using `float` function to parse the given double-type value, use the `atof` function from Python built-in `locale` module, which respects the system's locale preferences (see attached patch).
Comment 1 Git Bot editbugs 2020-01-15 11:52:31 CET
Gusti Ridhoni Syahputera referenced this bugreport in commit 378c7881fe8cced2a2202373d5674ca8067d73e2

Fix float parsing error (bug #16295)

https://git.xfce.org/apps/xfce4-screensaver/commit?id=378c7881fe8cced2a2202373d5674ca8067d73e2
Comment 2 Sean Davis editbugs 2020-01-15 11:52:55 CET
Awesome, thanks for the patch! Applied above.
Comment 3 Sean Davis editbugs 2020-01-15 11:57:40 CET
*** Bug 16350 has been marked as a duplicate of this bug. ***

Bug #16295

Reported by:
Gusti Syahputera
Reported on: 2019-12-22
Last modified on: 2020-01-15
Duplicates (1):
  • 16350 Will not let configure some themes, if LC_NUMERIC is set to locale that uses comma as decimal separator

People

Assignee:
Sean Davis
CC List:
1 user

Version

Attachments

Patch (865 bytes, patch)
2019-12-22 13:14 CET , Gusti Syahputera
no flags

Additional information