UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 19: surrogates not allowed

Bug #1498366 reported by Nils Fredrik Gjerull
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
HPLIP
Fix Committed
Undecided
Gaurav Sood
hplip (Debian)
Fix Released
Unknown

Bug Description

I use version 3.15.2-0ubuntu4.2 of hplip.

The attached document causes the UnicodeEncodeError in the /usr/lib/cups/filter/hpps filter.

It look like the document contains some surrogate escapes. I solved the problem by altering the file "/usr/share/hplip/base/sixext.py".

I changed "return s.encode("utf-8")" on line 109 with "return s.encode("utf-8", errors="surrogateescape")".

Revision history for this message
Nils Fredrik Gjerull (nfg) wrote :
description: updated
tags: added: surrogate unicode
Changed in hplip:
assignee: nobody → Gaurav Sood (gaurav-sood)
Revision history for this message
Max Meyer (maxmeyer) wrote :

I can confirm this bus on Arch Linux as well.

Name : hplip
Version : 3.15.11-1

~~~
D [28/Nov/2015:20:08:30 +0100] [Job 126] Started filter /usr/lib/cups/filter/pdftopdf (PID 27890)
D [28/Nov/2015:20:08:30 +0100] [Job 126] Started filter /usr/lib/cups/filter/pdftops (PID 27891)
D [28/Nov/2015:20:08:30 +0100] [Job 126] Started filter /usr/lib/cups/filter/hpps (PID 27892)
D [28/Nov/2015:20:08:30 +0100] [Job 126] Started backend /usr/lib/cups/backend/hp (PID 27893)
D [28/Nov/2015:20:08:30 +0100] [Job 126] pdftops - copying to temp print file "/var/spool/cups/tmp/06cf3565f04e8"
D [28/Nov/2015:20:08:30 +0100] [Job 126] Printer make and model: HP HP Color LaserJet Pro M252c10
D [28/Nov/2015:20:08:30 +0100] [Job 126] Running command line for pstops: pstops 126 d 'asdf' 1 'HPRGBEmulation=Adobe HPGenera
D [28/Nov/2015:20:08:30 +0100] [Job 126] Using image rendering resolution 600 dpi
D [28/Nov/2015:20:08:30 +0100] [Job 126] Running command line for gs: gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ps2write -sOUTPUTFILE=%stdout -dLanguag
D [28/Nov/2015:20:08:30 +0100] [Job 126] Started filter gs (PID 27895)
D [28/Nov/2015:20:08:30 +0100] [Job 126] Started filter pstops (PID 27896)
D [28/Nov/2015:20:08:30 +0100] [Job 126] PID 27890 (/usr/lib/cups/filter/pdftopdf) exited with no errors.
D [28/Nov/2015:20:08:30 +0100] [Job 126] STATE: +connecting-to-device
D [28/Nov/2015:20:08:30 +0100] [Job 126] Traceback (most recent call last):
D [28/Nov/2015:20:08:30 +0100] [Job 126] File "/usr/lib/cups/filter/hpps", line 186, in <module>
D [28/Nov/2015:20:08:30 +0100] [Job 126] os.write(output_fd, to_bytes_utf8('@PJL SET JOBNAME="%s"\x0a' % title))
D [28/Nov/2015:20:08:30 +0100] [Job 126] File "/usr/share/hplip/base/sixext.py", line 109, in to_bytes_utf8
D [28/Nov/2015:20:08:30 +0100] [Job 126] return s.encode("utf-8")
D [28/Nov/2015:20:08:30 +0100] [Job 126] UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 31: surrogates not allowed
D [28/Nov/2015:20:08:30 +0100] [Job 126] PID 27892 (/usr/lib/cups/filter/hpps) stopped with status 1.
D [28/Nov/2015:20:08:30 +0100] [Job 126] Hint: Try setting the LogLevel to "debug" to find out more.
D
~~~

Revision history for this message
Max Meyer (maxmeyer) wrote :

s/bus/bug/

Revision history for this message
Max Meyer (maxmeyer) wrote :

@nils

Your solution worked for me as well.

Changed in hplip (Debian):
status: Unknown → New
Revision history for this message
Max Meyer (maxmeyer) wrote :

@gaurav-sood Would you mind to fix this bug? There's a solution which works for me. I patched all new releases with this fix. And it always works.

Revision history for this message
Gaurav Sood (gaurav-sood) wrote :

Sorry for the delay. It will be fixed in latest version

Revision history for this message
Øyvind Stegard (oyvindstegard) wrote :

I can confirm that the suggested fix works for at least printing to a HP Color LaserJet M651 using Ubuntu 16.04. Any chance this can get backported ?

Revision history for this message
Max Meyer (maxmeyer) wrote :

@gaurav-sood Sorry for bothering you again, but this bug is still not fixed - at least not in the package distributed via Arch Linux. Can you confirm this? Since this really is a small fix, can you please merge it? Today I needed to patch the lib again on my own. :-(

Changed in hplip:
status: New → In Progress
Revision history for this message
Max Meyer (maxmeyer) wrote :
Changed in hplip:
status: In Progress → Fix Committed
Changed in hplip (Debian):
status: New → Confirmed
Changed in hplip (Debian):
status: Confirmed → Fix Released
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.