Encoding bug in hplip plugin installation

Asked by Alexander Korolkov

While trying to install driver for HP LaserJet 1020, I encountered a following error message:

HP Linux Imaging and Printing System (ver. 3.10.2)
Plugin Installer ver. 3.0

Copyright (c) 2001-9 Hewlett-Packard Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

Plug-in version: 3.10.2
Installed HPLIP version: 3.10.2
Number of files to install: 30

Done.

Downloading firmware to device hp:/usb/HP_LaserJet_1020?serial=FN0QWKG...
Traceback (most recent call last):
  File "/usr/share/hplip/ui4/plugindialog.py", line 338, in NextButton_clicked
    if d.downloadFirmware():
  File "/usr/share/hplip/base/device.py", line 2457, in downloadFirmware
    log.debug("%s bytes downloaded." % utils.commafy(bytes_written))
  File "/usr/share/hplip/base/utils.py", line 365, 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)

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu hplip Edit question
Assignee:
No assignee Edit question
Solved by:
Alexander Korolkov
Solved:
Last query:
Last reply:
Revision history for this message
Alexander Korolkov (telgnik) said :
#1

Oh, sorry, I've posted it in a wrong place. Will move it to bugs.

Anyway, I've solved this problem by commenting out the .encoding() part:
- return locale.format("%d", val, grouping=True).decode(locale.getpreferredencoding())
+ return locale.format("%d", val, grouping=True)

Unsure whether this .decode() is needed and where this 0xc2 byte comes from - it's just a string containing a decimal number.