unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: ng0 <ng0@libertad.pw>
Cc: guix-devel@gnu.org
Subject: Re: Trouble setting up hplip and cups - printer ppd fails
Date: Sat, 24 Dec 2016 16:23:00 +0100	[thread overview]
Message-ID: <20161224162300.65ceeb04@scratchpost.org> (raw)
In-Reply-To: <87d1ghpggj.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me>

Hi,

On Sat, 24 Dec 2016 14:08:44 +0000
ng0 <ng0@libertad.pw> wrote:

> > Traceback (most recent call last):
> >   File "/gnu/store/95vp3r6n9z7s85achc7a0b8aay1k73qq-hplip-3.16.11/share/hplip/setup.py", line 560, in <module>
> >     desc = nickname_pat.search(nickname).group(1)
> > TypeError: cannot use a string pattern on a bytes-like object

The reason that fails is because gzip.GzipFile always provides reads in binary mode. However, ppd files are not binary and nickname_pat is not binary either. So not sure what they were thinking...

                            if file_path.endswith('.gz'):
                                nickname = gzip.GzipFile(file_path, 'r').read(4096) # bytes, not str
                            else:
                                nickname = open(file_path, 'r').read(4096) # str

                            try:
                                desc = nickname_pat.search(nickname).group(1)
                            except AttributeError:
                                desc = ''

A quick fix would be to gunzip the ppd file and specify it without ".gz" in hp-setup. You don't need to patch anything for this.

A better fix with patching would be: Replacing

                                nickname = gzip.GzipFile(file_path, 'r').read(4096)

by

                                nickname = gzip.GzipFile(file_path, 'r').read(4096).decode("utf-8")

.

An even better fix would be to find out which parts are supposed to be binary and which are supposed to be text - use the correct functions accordingly and upstream it.

  reply	other threads:[~2016-12-24 15:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-24 13:56 Trouble setting up hplip and cups - printer ppd fails ng0
2016-12-24 14:08 ` ng0
2016-12-24 15:23   ` Danny Milosavljevic [this message]
2016-12-29 22:12     ` Ludovic Courtès
2016-12-29 22:38       ` ng0

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161224162300.65ceeb04@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=guix-devel@gnu.org \
    --cc=ng0@libertad.pw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).