Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 771969 - net-print/hplip-3.20.11-r1: hp-align fails at /usr/share/hplip/base/maint.py:433 with TypeError: sequence item 0: expected str instance, bytes found
Summary: net-print/hplip-3.20.11-r1: hp-align fails at /usr/share/hplip/base/maint.py:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Daniel Pielmeier
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2021-02-21 19:09 UTC by Andrew Savchenko
Modified: 2021-02-23 14:48 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge.info,12.68 KB, text/plain)
2021-02-21 19:09 UTC, Andrew Savchenko
Details
hplip-3.20.11-binary-to-string.patch (hplip-3.20.11-binary-to-string.patch,4.80 KB, patch)
2021-02-21 19:10 UTC, Andrew Savchenko
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Savchenko gentoo-dev 2021-02-21 19:09:22 UTC
Created attachment 687945 [details]
emerge --info

Hi!

hp-align fails after reading user input with correction values (see log below).

This happens because py2->3 porting was not complete and binary values were mixed into string's join operator. Proposed patch fixes this issue and hp-align works properly: I verified that boxes are aligned as expected.

$ hp-align

HP Linux Imaging and Printing System (ver. 3.20.11)
Printer Cartridge Alignment Utility ver. 5.0

Copyright (c) 2001-18 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.

Using device : hp:/usb/Deskjet_5400_series?serial=XXXXXXXXXX

A page will be printed.
Please load plain paper into the printer. Press <enter> to continue or 'q' to quit:
Enter the numbered box on line A where the inner lines best line up with the outer lines (1-23): 12
Enter the numbered box on line B where the inner lines best line up with the outer lines (1-17): 11
Enter the numbered box on line C where the inner lines best line up with the outer lines (1-23): 12
Enter the numbered box on line D where the inner lines best line up with the outer lines (1-23): 10
Enter the numbered box on line E where the inner lines best line up with the outer lines (1-9): 3
Enter the numbered box on line F where the inner lines best line up with the outer lines (1-9): 3
Enter the numbered box on line G where the inner lines best line up with the outer lines (1-9): 4
Enter the numbered box on line H where the inner lines best line up with the outer lines (1-9): 3
Traceback (most recent call last):
  File "/usr/bin/hp-align", line 207, in <module>
    maint.AlignType10(d, tui.load_paper_prompt, type10and11and14Align)
  File "/usr/share/hplip/base/maint.py", line 397, in AlignType10
    alignType10Phase2(dev, values, pattern)
  File "/usr/share/hplip/base/maint.py", line 433, in alignType10Phase2
    i, p = 0, ''.join([pcl.UEL, '\n'])
TypeError: sequence item 0: expected str instance, bytes found

$ eix -e hplip
     Installed versions:  3.20.11(09:38:47 PM 12/26/2020)(X doc hpcups hpijs libnotify scanner -fax -kde -libressl -libusb0 -minimal -parport -policykit -qt5 -snmp -static-ppds KERNEL="linux" PYTHON_SINGLE_TARGET="python3_8 -python3_6 -python3_7")
Comment 1 Andrew Savchenko gentoo-dev 2021-02-21 19:10:19 UTC
Created attachment 687948 [details, diff]
hplip-3.20.11-binary-to-string.patch

Fix binary to string conversion when python3 is used

Python 2 -> 3 compatibility was not complete and hp-align failed as
follows:

Traceback (most recent call last):
  File "/usr/bin/hp-align", line 207, in <module>
    maint.AlignType10(d, tui.load_paper_prompt, type10and11and14Align)
  File "/usr/share/hplip/base/maint.py", line 397, in AlignType10
    alignType10Phase2(dev, values, pattern)
  File "/usr/share/hplip/base/maint.py", line 433, in alignType10Phase2
    i, p = 0, ''.join([pcl.UEL, '\n'])
TypeError: sequence item 0: expected str instance, bytes found

This happened because of using binary values within string's join.
Comment 2 Daniel Pielmeier gentoo-dev 2021-02-21 19:21:44 UTC
Thanks for the patch. I guess it is not available upstream?
Comment 3 Andrew Savchenko gentoo-dev 2021-02-21 20:33:08 UTC
(In reply to Daniel Pielmeier from comment #2)
> Thanks for the patch. I guess it is not available upstream?

No, it is not. I just wrote it :) Do you want me to open a bug on the hplip launchpad? If yes, please tell me how to link with Gentoo's bugzilla properly: as I see the Launchpad can track bugs from our bugzilla, but I have no idea how.
Comment 4 Daniel Pielmeier gentoo-dev 2021-02-21 20:43:47 UTC
(In reply to Andrew Savchenko from comment #3)
> (In reply to Daniel Pielmeier from comment #2)
> > Thanks for the patch. I guess it is not available upstream?
> 
> No, it is not. I just wrote it :) Do you want me to open a bug on the hplip
> launchpad? If yes, please tell me how to link with Gentoo's bugzilla
> properly: as I see the Launchpad can track bugs from our bugzilla, but I
> have no idea how.

Ah, okay. Thanks again!

Would be great if you could bring this upstream. At least they are aware of it then.

In the launchpad bug below the title you can add the tracking of the Gentoo bug by clicking "Also affects distribution/package".
There select "Gentoo Linux" from the Distribution drop down, specify "hplip" as the source package (not that important) and add the URL to the Gentoo bug.
I am not sure if it does now but in the past it did not support the short https://bugs.gentoo.org/771969 but https://bugs.gentoo.org/show_bug.cgi?id=771969 instead.
Comment 5 Andrew Savchenko gentoo-dev 2021-02-21 21:31:01 UTC
Done!
Comment 6 Larry the Git Cow gentoo-dev 2021-02-23 14:48:49 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc00c3e614996bac5e357924fdc1c617d9b8d4c0

commit fc00c3e614996bac5e357924fdc1c617d9b8d4c0
Author:     Daniel Pielmeier <billie@gentoo.org>
AuthorDate: 2021-02-23 14:47:40 +0000
Commit:     Daniel Pielmeier <billie@gentoo.org>
CommitDate: 2021-02-23 14:48:12 +0000

    net-print/hplip: Version bump.
    
    Thanks to Andrew Savchenko for the reports.
    
    Closes: https://bugs.gentoo.org/771969
    Closes: https://bugs.gentoo.org/771972
    Package-Manager: Portage-3.0.13, Repoman-3.0.2
    Signed-off-by: Daniel Pielmeier <billie@gentoo.org>

 net-print/hplip/Manifest            |   2 +
 net-print/hplip/hplip-3.21.2.ebuild | 288 ++++++++++++++++++++++++++++++++++++
 2 files changed, 290 insertions(+)