Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:code': 0.07; 'versions,': 0.07; 'advice?': 0.09; 'subject:string': 0.09; 'python': 0.11; 'bug': 0.12; 'finney': 0.16; 'subject: \n ': 0.16; 'subject:between': 0.16; 'version?': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'to:name:python- list@python.org': 0.22; 'unicode': 0.24; 'mon,': 0.24; '15,': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'fixed': 0.29; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'this.': 0.32; 'problem': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'ben': 0.38; 'needed': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'applicable': 0.60; 'complete': 0.62; 'kind': 0.63; 'skip:\xe2 10': 0.65; 'between': 0.67; 'believe': 0.68; 'six': 0.68; '8bit%:27': 0.74; '8bit%:43': 0.74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; bh=k20MQvOYhiINUPsXInU9aepCcSTCK+Pws7kfFOHF8pc=; b=kK2cW8uXD+v8KDlJnJetHhcEI6G7yCVx4iSA7ukB6DTVVxK+1qe7FNeQmf13zEiSEa Llhyv+ZngAG2GTmDhTQqCUjOPat1fdkk+1tXiDxHlxz9RYK7+1XtNyDwtn4n+IFFG8L0 9MgKeNu2XNyKowmQFTSFbCFuwA7v6EHR+TZUDsT+r3E9iDALpo8/ZME8WJnxPazRxSnA GpC/HjyW4o5AD0PX1QXTh0BqH22KyKp9vtIxjM5ok9huwz5xHuzwvsIq3ou+ynRixgN3 gt4qlsiCerYmbURotLgiOSYiCGOdjXE0ocae4EZomgP8sEkZ7DLLX21TwDCO6g9mFSKy r/Mg== X-Received: by 10.202.204.208 with SMTP id c199mr17316614oig.42.1418629195828; Sun, 14 Dec 2014 23:39:55 -0800 (PST) MIME-Version: 1.0 Sender: zachary.ware@gmail.com In-Reply-To: <85wq5tpe0g.fsf@benfinney.id.au> References: <85wq5tpe0g.fsf@benfinney.id.au> From: Zachary Ware Date: Mon, 15 Dec 2014 01:39:35 -0600 X-Google-Sender-Auth: XIVAM0fjkS9ouPicWPP43Fy2i5Q Subject: Re: Portable code: __import__ demands different string types between 2 and 3 To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418629204 news.xs4all.nl 2837 [2001:888:2000:d::a6]:33527 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82553 On Mon, Dec 15, 2014 at 1:29 AM, Ben Finney wr= ote: > How can I get that =E2=80=98__import__=E2=80=99 call, complete with its = =E2=80=98fromlist=E2=80=99 > parameter, working correctly under both Python 2 and Python 3, keeping > the =E2=80=98unicode_literals=E2=80=99 setting? How about "str('bar')"? > If some kind of kludge is needed to make it work between versions, is > this a bug which should be fixed so =E2=80=9Cuse Unicode for text=E2=80= =9D remains > applicable advice? Fixed in which version? The problem is that Python 2 mixes the notions of strings and bytestrings, and the solution is Python 3. I believe six also has a "give me a native string" function to help with th= is. --=20 Zach