Hplip does not work with Python3: Unicode error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| HPLIP |
Undecided
|
Unassigned | ||
| hplip (Arch Linux) |
New
|
Undecided
|
Unassigned | |
| hplip (Debian) |
Fix Released
|
Unknown
|
||
| hplip (Fedora) |
Confirmed
|
Undecided
|
||
| hplip (Gentoo Linux) |
Fix Released
|
Medium
|
Bug Description
The hp-setup program crashes with a UnicodeDecodeError when it tries to detect my Photosmart 2575 printer. I am running Arch Linux which has switched to using Python3 by default (/usr/bin/python is a symlink to python3).
Below is a part of a debugging session demonstrating the problem. The variable x contains (part of) the response from my printer to the multicast query sent on the network. The to_string_utf8 function is supposed to convert the contents of the byte array to UTF-8, but chokes on the 0xf0 in position 364, presumably because the bytes aren't all strictly ASCII codepoints.
Running the program using Python2 does not trigger this bug.
My printer is a HP Photosmart 2575, Python version 3.4.3, Python2 version 2.7.10, Hplip version hplip 3.15.6-1 (Arch Linux).
(Pdb) n
> /usr/share/
-> struct.
(Pdb) n
> /usr/share/
-> x = struct.
(Pdb) n
> /usr/share/
-> x= to_string_utf8(x)
(Pdb) p x
b'(x-hp-
(Pdb) n
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 364: invalid continuation byte
> /usr/share/
-> x= to_string_utf8(x)
(Pdb)
Gaurav Sood (gaurav-sood) wrote : | #1 |
Johan Myréen (r-ubuntuone-v) wrote : | #2 |
Yes, now the decode functions ignore the errors and the setup succeeds.
Thank you.
Georges Toth (georges-toth) wrote : | #3 |
The latest Debian Stretch version is affected by this bug, which is version 3.16.11+repack0-2.
I ended up patching the "/usr/share/
Is there any information on when this quite old fix will make it into the upstream package?
Changed in hplip (Debian): | |
importance: | Undecided → Unknown |
status: | New → Unknown |
Changed in hplip (Debian): | |
status: | Unknown → Confirmed |
kritika arora (kritika-arora1) wrote : | #4 |
Hi,
The required changes has been included in HPLIP source and will be made available in the next release.
Thanks.
Changed in hplip: | |
status: | New → Fix Committed |
Georges Toth (georges-toth) wrote : | #5 |
Hi,
Thank you!
Changed in hplip (Debian): | |
status: | Confirmed → Fix Committed |
Changed in hplip (Debian): | |
status: | Fix Committed → Fix Released |
According to #4 this has been fixed, however the same issue came up in Gentoo recently. Applying the patch from #1 fixed the issue.
What could be the problem here. Was this fix reverted or changed in another way. Maybe there is a regression somewhere.
Changed in hplip (Gentoo Linux): | |
importance: | Unknown → Medium |
status: | Unknown → New |
Changed in hplip (Gentoo Linux): | |
status: | New → Fix Released |
Changed in hplip: | |
status: | Fix Committed → New |
Francois Jaouen (francois-jaouen) wrote : | #7 |
Tested version 3.18.4 on Arch, the problem is still there. The proposed patch has not been applied :
% hp-probe -bnet
HP Linux Imaging and Printing System (ver. 3.18.4)
(...)
\Traceback (most recent call last):
File "/usr/bin/
devices = device.
File "/usr/share/
detected_
File "/usr/share/
x= to_string_utf8(x)
File "/usr/share/
return s.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 365-366: invalid continuation byte
The printer is an HP Photosmart C6480 All in One.
Francois Jaouen (francois-jaouen) wrote : | #8 |
Look like a duplicate of https:/
Description of problem:
Try to detect my network printer HP Photosmart C8260 using the command :
% hp-probe -bnet -ldebug
Output of the command :
HP Linux Imaging and Printing System (ver. 3.18.4)
Printer Discovery Utility ver. 4.1
Copyright (c) 2001-15 HP 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.
-------
| DEVICE DISCOVERY |
-------
Probing network for printers. Please wait, this will take approx. 10 seconds...
hp-probe[1859]: debug: {}
hp-probe[1859]: debug: 0000: 01 07 01 a7 00 00 65 6e 00 03 00 00 00 00 01 97 28 78 2d 68 70 2d 76 65 72 3d 30 31 29 28 78 2d ......en.
hp-probe[1859]: debug: 0020: 68 70 2d 6d 61 63 3d 30 30 31 65 30 62 39 61 35 63 63 63 29 28 78 2d 68 70 2d 6e 75 6d 5f 70 6f hp-mac=
hp-probe[1859]: debug: 0040: 72 74 3d 30 31 29 28 78 2d 68 70 2d 69 70 3d 31 39 32 2e 31 36 38 2e 32 34 36 2e 30 31 31 29 28 rt=01)(
hp-probe[1859]: debug: 0060: 78 2d 68 70 2d 68 6e 3d 48 50 39 41 35 43 43 43 29 28 78 2d 68 70 2d 70 31 3d 4d 46 47 3a 48 50 x-hp-hn=
hp-probe[1859]: debug: 0080: 3b 4d 44 4c 3a 50 68 6f 74 6f 73 6d 61 72 74 20 43 36 32 30 30 20 73 65 72 69 65 73 3b 43 4d 44 ;MDL:Photosmart C6200 series;CMD
hp-probe[1859]: debug: 00a0: 3a 4d 4c 43 2c 50 43 4c 2c 50 4d 4c 2c 44 57 2d 50 43 4c 2c 44 45 53 4b 4a 45 54 2c 44 59 4e 3b :MLC,PCL,
hp-probe[1859]: debug: 00c0: 31 32 38 34 2e 34 44 4c 3a 34 64 2c 34 65 2c 31 3b 43 4c 53 3a 50 52 49 4e 54 45 52 3b 44 45 53 1284.4DL:
hp-probe[1859]: debug: 00e0: 3a 43 43 39 38 38 3b 53 4e 3a 4d 59 37 43 49 48 35 31 30 50 30 35 30 36 3b 53 3a 30 33 38 30 38 :CC988;
hp-probe[1859]: debug: 0100: 38 43 34 38 34 30 30 31 30 32 31 30 30 37 38 63 62 30 30 30 30 30 34 31 62 38 30 34 32 37 34 36 8C4840010210078
hp-probe[1859]: debug: 0120: 62 38 30 34 34 38 34 37 62 38 30 34 34 65 34 34 62 38 30 34 36 34 34 38 62 38 30 30 35 35 34 35 b8044847b8044e4
hp-probe[1859]: debug: 0140: 62 38 30 34 36 34 3b 5a 3a 30 31 30 32 2c 30 35 30 30 30 30 30 39 30 31 36 61 38 35 30 31 33 32 b80464;
hp-probe[1859]: debug: 0160: 34 35 30 31 33 32 34 35 30 31 33 32 34 35 30 31 33 32 34 31 30 31 33 32 34 35 21 73 54 f0 a0 29 450132450132450
hp-probe[1859]: debug: 0180: 4d 7d 21 73 55 ac ff ff fa 40 a0 39 c7 3f 29 28 78 2d 68 70 2d 67 75 69 64 3d 30 30 31 65 30 62 M}!sU..
hp-probe[1859]: debug: 01a0: 39 61 35 63 63 63 29 9a5ccc)
Traceback (most recent call last):
File "/usr/bin/
devices = device.
File "/usr/share/
detected_
File "/usr/share/
Created attachment 1429138
File: backtrace
Created attachment 1429139
File: cgroup
Created attachment 1429140
File: cpuinfo
Created attachment 1429141
File: environ
Created attachment 1429142
File: mountinfo
Created attachment 1429143
File: namespaces
Created attachment 1429144
File: open_fds
Created attachment 1429145
File: hp-probe.log
Created attachment 1528767
Patch provided in Launchpad bug
Patch for /usr/share/
This is exposed by the switch to using Python3 by default. It's a known bug in HPlip that other distributions have seen when they switched to Python3 by default. It is still present in Fedora 29 and the new HPlip. There's a patch that makes things work (but is probably not the Right Way) by ignoring the UTF-8 conversion errors. Using the patch, everything works for me (and people on other distros.)
Changed in hplip (Fedora): | |
importance: | Unknown → Undecided |
status: | Unknown → Confirmed |
Please apply this patch and see if it works hplip/base/ sixext. py
1. Take a back up of /usr/share/
1. Download this patch in any folder and navigate to that folder
2. Apply this patch as a root user using the following command
'patch /usr/share/ hplip/base/ sixext. py < sixext.patch'