From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: Re: Trouble setting up hplip and cups - printer ppd fails Date: Sat, 24 Dec 2016 16:23:00 +0100 Message-ID: <20161224162300.65ceeb04@scratchpost.org> References: <87fuldph04.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> <87d1ghpggj.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKoAF-00089W-A6 for guix-devel@gnu.org; Sat, 24 Dec 2016 10:23:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKoAA-0006AL-Cf for guix-devel@gnu.org; Sat, 24 Dec 2016 10:23:15 -0500 Received: from dd1012.kasserver.com ([85.13.128.8]:48914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cKoAA-00068y-5C for guix-devel@gnu.org; Sat, 24 Dec 2016 10:23:10 -0500 In-Reply-To: <87d1ghpggj.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: ng0 Cc: guix-devel@gnu.org Hi, On Sat, 24 Dec 2016 14:08:44 +0000 ng0 wrote: > > Traceback (most recent call last): > > File "/gnu/store/95vp3r6n9z7s85achc7a0b8aay1k73qq-hplip-3.16.11/share/hplip/setup.py", line 560, in > > 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.