Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7F88C429E37 for ; Wed, 4 Jan 2012 10:07:25 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WuBoHRh-rV7f for ; Wed, 4 Jan 2012 10:07:24 -0800 (PST) Received: from mail-gw3.nixu.fi (mail-gw3.nixu.fi [193.209.237.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 99C41429E21 for ; Wed, 4 Jan 2012 10:07:24 -0800 (PST) Received: from pps.filterd (mail-gw3 [127.0.0.1]) by mail-gw3.nixu.fi (8.14.4/8.14.4) with SMTP id q04I5k5X015721; Wed, 4 Jan 2012 20:07:12 +0200 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31]) by mail-gw3.nixu.fi with ESMTP id 114cs0xcej-1 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 04 Jan 2012 20:07:12 +0200 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31]) by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q04I7BeO008541; Wed, 4 Jan 2012 20:07:11 +0200 From: Tomi Ollila To: Sebastian Spaeth , Justus Winter <4winter@informatik.uni-hamburg.de>, notmuch@notmuchmail.org Subject: Re: [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3 In-Reply-To: <87hb0ekudt.fsf@SSpaeth.de> References: <1323860305-15802-1-git-send-email-4winter@informatik.uni-hamburg.de> <1323860305-15802-6-git-send-email-4winter@informatik.uni-hamburg.de> <87hb0ekudt.fsf@SSpaeth.de> User-Agent: Notmuch/0.10.2+157~g442d405 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110, 1.0.211, 0.0.0000 definitions=2012-01-04_07:2012-01-04, 2012-01-04, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1012030000 definitions=main-1201040166 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2012 18:07:25 -0000 On Mon, 02 Jan 2012 16:15:58 +0100, Sebastian Spaeth wrote: > Happy new year. Pushed patches 1-4 of this series so far. Looking fine, > but ugh, the below seems like a rather ugly hack in a function that is > probably called quite often. > > Isn't there a more pretty variant avoiding these sys.version_info checks > all over the place? > > > @@ -200,9 +201,9 @@ def _str(value): > > > > C++ code expects strings to be well formatted and > > unicode strings to have no null bytes.""" > > - if not isinstance(value, basestring): > > + if not isinstance(value, basestring if sys.version_info[0] == 2 else str): > > raise TypeError("Expected str or unicode, got %s" % str(type(value))) > > - if isinstance(value, unicode): > > + if sys.version_info[0] == 3 or isinstance(value, unicode): > > return value.encode('UTF-8') > > return value Does the Python3StringMixIn stuff in later patches already handle this patch -- and making this obsolete ? Tomi