Deprecated locale.format() in indicator.py

Bug #2063547 reported by Peter Kokot
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
indicator-cpufreq (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

System: Ubuntu: 24.04

The locale.format() function has been deprecated in Python 3.7 and removed in 3.12. Instead locale.format_string() can be used in the indicator.py file by a simple rename. Otherwise this error occurs when launching indicator-cpufreq:

Traceback (most recent call last):
  File "/usr/bin/indicator-cpufreq", line 85, in <module>
    ind = MyIndicator(options.show_frequency)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/indicator_cpufreq/indicator.py", line 78, in __init__
    menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_frequency(freq))
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/indicator_cpufreq/indicator.py", line 34, in readable_frequency
    label = _("%s GHz") % locale.format(_("%.2f"), f / 1.0e6)
                          ^^^^^^^^^^^^^
AttributeError: module 'locale' has no attribute 'format'. Did you mean: '_format'?

Related branches

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in indicator-cpufreq (Ubuntu):
status: New → Confirmed
Revision history for this message
krab84 (krab84) wrote :

replacing 'format' with '_format' fixes the problem

Revision history for this message
krab84 (krab84) wrote :

although it is recommended to replace 'locale.format' with 'locale.format_string'. Also works but is safer.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.