Bug 984167 - [abrt] hplip-gui-3.13.6-2.fc19: utils.py:466:commafy:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3: ordinal not in range(128)
[abrt] hplip-gui-3.13.6-2.fc19: utils.py:466:commafy:UnicodeDecodeError: 'asc...
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: hplip (Show other bugs)
19
x86_64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Tim Waugh
Fedora Extras Quality Assurance
abrt_hash:c7680fd750dc9034cb07063f680...
:
: 919792 1128895 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-13 03:09 EDT by dimapunk80
Modified: 2015-02-04 13:43 EST (History)
6 users (show)

See Also:
Fixed In Version: hplip-3.14.6-3.fc19
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-02-04 13:43:13 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
File: backtrace (674 bytes, text/plain)
2013-07-13 03:09 EDT, dimapunk80
no flags Details
File: core_backtrace (290 bytes, text/plain)
2013-07-13 03:09 EDT, dimapunk80
no flags Details
File: environ (1.47 KB, text/plain)
2013-07-13 03:09 EDT, dimapunk80
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Launchpad 1308472 None None None Never

  None (edit)
Description dimapunk80 2013-07-13 03:09:04 EDT
Version-Release number of selected component:
hplip-gui-3.13.6-2.fc19

Additional info:
reporter:       libreport-2.1.5
cmdline:        /usr/bin/python /usr/bin/hp-toolbox
dso_list:       hplip-3.13.6-2.fc19.x86_64
executable:     /usr/bin/hp-toolbox
kernel:         3.9.9-301.fc19.x86_64
runlevel:       N 5
uid:            1000

Truncated backtrace:
utils.py:466:commafy:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3: ordinal not in range(128)

Traceback (most recent call last):
  File "/usr/share/hplip/ui4/firmwaredialog.py", line 96, in downloadFirmware
    ok = d.downloadFirmware()
  File "/usr/share/hplip/base/device.py", line 2697, in downloadFirmware
    log.debug("%s bytes downloaded." % utils.commafy(bytes_written))
  File "/usr/share/hplip/base/utils.py", line 466, in commafy
    return unicode(locale.format("%d", val, grouping=True))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3: ordinal not in range(128)

Local variables in innermost frame:
val: 222443
Comment 1 dimapunk80 2013-07-13 03:09:09 EDT
Created attachment 772958 [details]
File: backtrace
Comment 2 dimapunk80 2013-07-13 03:09:13 EDT
Created attachment 772959 [details]
File: core_backtrace
Comment 3 dimapunk80 2013-07-13 03:09:16 EDT
Created attachment 772960 [details]
File: environ
Comment 4 Jiri Popelka 2013-07-15 09:30:46 EDT
No idea what went wrong, the following command works for me with Russian locale:
python -c 'import locale; print unicode(locale.format("%d", 222443, grouping=True))'
Comment 5 Jiri Popelka 2013-07-15 09:31:25 EDT
*** Bug 919792 has been marked as a duplicate of this bug. ***
Comment 8 Tim Waugh 2013-11-27 03:52:50 EST
Are you able to reproduce this problem, or did it only happen once?
Comment 9 Ville Skyttä 2014-04-15 14:53:59 EDT
I'm seeing this with 3.13.11-4 on F-20. Happens after entering root username/password when clicking "add printer" in the dialog that follows downloading the proprietary plugin. This is with hp-setup launched from the console when setting up a LaserJet 1000 series printer. Language = US English, formats setting = Finnish.

Traceback (most recent call last):
  File "/usr/share/hplip/ui4/setupdialog.py", line 1251, in NextButton_clicked
    self.addPrinter()
  File "/usr/share/hplip/ui4/setupdialog.py", line 954, in addPrinter
    self.flashFirmware()
  File "/usr/share/hplip/ui4/setupdialog.py", line 972, in flashFirmware
    if d.downloadFirmware():
  File "/usr/share/hplip/base/device.py", line 2720, in downloadFirmware
    log.debug("%s bytes downloaded." % utils.commafy(bytes_written))
  File "/usr/share/hplip/base/utils.py", line 466, in commafy
    return locale.format("%d", val, grouping=True).decode(locale.getpreferredencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3: ordinal not in range(128)
Comment 10 Tim Waugh 2014-04-16 06:34:17 EDT
Oh, I see. 0xc2 is the first byte of a non-breaking space (or something similar) used for digit grouping in Finnish.

The problem comes about because of a mismatch of encodings:

LANG=C python << "EOF"
import locale
locale.setlocale(locale.LC_ALL, "fi_FI.UTF-8")
locale.format("%d", 1000, grouping=True).decode(locale.getpreferredencoding())
EOF

Here, getpreferredencoding() is thinking about locale "C", but locale.format() is thinking about "fi_FI.UTF-8".

My guess is that changing locale.getpreferredencoding() to locale.getlocale(locale.LC_NUMERIC)[1] will fix it.

I've checked that fix in on master.
Comment 11 Ville Skyttä 2014-04-17 02:04:11 EDT
Thanks, I'll try to remember to try out the fix when I have access to the machine again (which might take a while).
Comment 12 Ville Skyttä 2014-04-21 06:51:51 EDT
The change in master is broken:

    $ python
    >>> import locale
    >>> locale.getlocale(locale.LC_NUMERIC()[1])
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'int' object is not callable

Comment 10 seems to have the correct syntax, locale.getlocale(locale.LC_NUMERIC)[1]
Comment 13 Tim Waugh 2014-04-22 06:14:51 EDT
Oops, sorry, fix coming up.
Comment 14 Tim Waugh 2014-08-12 06:02:58 EDT
*** Bug 1128895 has been marked as a duplicate of this bug. ***
Comment 15 Fedora End Of Life 2015-01-09 17:35:03 EST
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Note You need to log in before you can comment on or make changes to this bug.