From patchwork Thu Jan 13 08:49:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Wallenstein X-Patchwork-Id: 78682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 8905EB70F6 for ; Thu, 13 Jan 2011 19:49:54 +1100 (EST) Received: from mailout04.t-online.de (mailout04.t-online.de [194.25.134.18]) by ozlabs.org (Postfix) with ESMTP id 71078B70EA for ; Thu, 13 Jan 2011 19:49:52 +1100 (EST) Received: from fwd04.aul.t-online.de (fwd04.aul.t-online.de ) by mailout04.t-online.de with smtp id 1PdIsS-0006qj-OR; Thu, 13 Jan 2011 09:49:52 +0100 Received: from localhost (bjnkM2ZUQhWbuddJ4Eyp3m98NfAaZfiQ+YRSnhCjPvO0Mby7oke8iOphtcSH8nxZfN@[84.139.36.93]) by fwd04.t-online.de with esmtp id 1PdIsJ-0X7IBs0; Thu, 13 Jan 2011 09:49:43 +0100 Date: Thu, 13 Jan 2011 09:49:42 +0100 From: Dirk Wallenstein To: Jeremy Kerr Subject: Re: [PATCH] Decode patch from UTF-8 while parsing from stdin Message-ID: <20110113084942.GB12433@zap> References: <1265340805-25653-1-git-send-email-madduck@madduck.net> <1291977005.3970.3.camel@mattotaupa> <201012130837.25211.jk@ozlabs.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201012130837.25211.jk@ozlabs.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-ID: bjnkM2ZUQhWbuddJ4Eyp3m98NfAaZfiQ+YRSnhCjPvO0Mby7oke8iOphtcSH8nxZfN X-TOI-MSGID: 7ac73cb4-4072-4dec-870e-8550c90e9e51 Cc: patchwork@lists.ozlabs.org, Paul Menzel X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org On Mon, Dec 13, 2010 at 08:37:25AM +0800, Jeremy Kerr wrote: > Hi Paul, > > > I think this patch needs to be reapplied, after the branch change(?) in > > March 2010 [1]. > > Thanks, good catch, I've reapplied it. This does now decode twice and raises an exception (on both paths). I don't see a reason for the second time, but attached is a patch that makes it conditional. Try it with this (the copyright sign will be decoded twice): http://patchwork.freedesktop.org/patch/3648/ diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index 24631b7..57b25c8 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -63,7 +63,10 @@ def parse_patch(text): lc = (0, 0) hunk = 0 - for line in text.decode('utf-8').split('\n'): + if not isinstance(text, unicode): + text = unicode(text, 'utf-8') + + for line in text.split('\n'): line += '\n' if state == 0: