From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Oct 29 18:30:01 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A72B45F5 for ; Mon, 29 Oct 2012 18:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 7BE6F8FC18 for ; Mon, 29 Oct 2012 18:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q9TIU14c071295 for ; Mon, 29 Oct 2012 18:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q9TIU19c071288; Mon, 29 Oct 2012 18:30:01 GMT (envelope-from gnats) Resent-Date: Mon, 29 Oct 2012 18:30:01 GMT Resent-Message-Id: <201210291830.q9TIU19c071288@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ruslan Mahmatkhanov Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5B1535D3 for ; Mon, 29 Oct 2012 18:28:18 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 3FB368FC0A for ; Mon, 29 Oct 2012 18:28:18 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9TISI9a081888 for ; Mon, 29 Oct 2012 18:28:18 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q9TISID9081887; Mon, 29 Oct 2012 18:28:18 GMT (envelope-from nobody) Message-Id: <201210291828.q9TISID9081887@red.freebsd.org> Date: Mon, 29 Oct 2012 18:28:18 GMT From: Ruslan Mahmatkhanov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/173195: Tools/scripts/getpatch: fix runtime in a case when patch contains non-ascii chars X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Oct 2012 18:30:01 -0000 >Number: 173195 >Category: ports >Synopsis: Tools/scripts/getpatch: fix runtime in a case when patch contains non-ascii chars >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Oct 29 18:30:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Ruslan Mahmatkhanov >Release: 10.0-CURRENT >Organization: >Environment: 10.0-CURRENT amd64 >Description: Sofian (sbz, author of this script) is already aware of it. I filing this pr to make sure it will not lost. Example session: """ # /usr/ports/Tools/scripts/getpatch ports/172280 [+] Fetching patch for pr ports/172280 Traceback (most recent call last): File "/usr/ports/Tools/scripts/getpatch", line 192, in main() File "/usr/ports/Tools/scripts/getpatch", line 189, in main gp.get(only_last=args.last, output_stdout=args.stdout) File "/usr/ports/Tools/scripts/getpatch", line 84, in get self.write(p, data) File "/usr/ports/Tools/scripts/getpatch", line 60, in write f.write(data.decode()) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 99: ordinal not in range(128) """ Attached patch fixing the issue. >How-To-Repeat: >Fix: Patch attached with submission follows: --- getpatch.orig 2012-10-16 15:13:36.000000000 +0400 +++ getpatch 2012-10-16 15:23:31.000000000 +0400 @@ -29,6 +29,7 @@ # MAINTAINER= sbz@FreeBSD.org import argparse +import codecs import re import sys if sys.version_info.major == 3: @@ -56,8 +57,8 @@ def write(self, filename, data): if filename.endswith(('.patch', '.txt')): filename = filename[:filename.rindex('.')]+'.diff' - f=open(filename, 'w') - f.write(data.decode()) + f = codecs.open(filename, encoding='utf-8', mode='w') + f.write(data.decode('utf-8')) f.close() self.out("[+] %s created" % filename) >Release-Note: >Audit-Trail: >Unformatted: