Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3a.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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python.': 0.02; 'scripts': 0.03; 'subject:Python': 0.06; 'python': 0.11; 'subject:library': 0.16; 'subject:requests': 0.16; 'tokenize': 0.16; 'top-level': 0.16; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'feb': 0.22; 'appears': 0.22; 'import': 0.22; 'issue.': 0.22; 'mon,': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; "doesn't": 0.30; 'absolute': 0.30; 'message-id:@mail.gmail.com': 0.30; 'this.': 0.32; 'brian': 0.33; 'subject:the': 0.34; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'library.': 0.36; 'thank': 0.38; 'problems': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'ian': 0.60; "you're": 0.61; 'first': 0.61; 'happen': 0.63; 'billing': 0.74; '2015': 0.84; 'shadow': 0.84; 'whereas': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=U/WmEH4JMArv/px4eqp/a/xKB4g3FkKISAJvaPDprAU=; b=sYEVAnsEUAQrd+eUElSNh3ShqNATnid7Wf6nnjsv1WbjKwYCPTlsXoolwfHTleFo+b 9q3RlAhOZafrLg74hNKCvgjt8vGnSjsLaBajjdwwOakYkNADlHtCFu2XkozkuFd/scxK nGRKk63ARW7XY6vt/ijDMcyDmfDJjydtGuDhGDlFfVkmRrpsEwrlP2VwhEj17y7UnZhN wuwWeo9gmPkmYyLdvCr9aYKIMYdvMR34xWnl2s/bE1Rowf2+kJfpTIZD3YlmSXwFpX51 NG3a930wIB10wpYhjV64pFp6QtqMjdoZBs3YOOjMEh74Nhz1BhI2LH2/3vf+QW8ArtD6 vOsw== X-Received: by 10.68.218.196 with SMTP id pi4mr33053576pbc.124.1423521783386; Mon, 09 Feb 2015 14:43:03 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <9b2a1b9d-4f1b-4786-a3a6-2d414074da6f@googlegroups.com> <96003963-8ca1-4b62-811d-05d6f6a5709d@googlegroups.com> <97b23ac0-c363-43d0-815e-198354d39c58@googlegroups.com> From: Ian Kelly Date: Mon, 9 Feb 2015 15:42:23 -0700 Subject: Re: Python 3 and the requests library To: Python Content-Type: text/plain; charset=UTF-8 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423521786 news.xs4all.nl 2870 [2001:888:2000:d::a6]:50799 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85408 On Mon, Feb 9, 2015 at 2:37 PM, Brian wrote: > Thank you, Ian and Zack! That was exactly the issue. Apparently, having a token.py script (one of my first Python 2 scripts to get an authorization token from a billing server) is OK for Python 2 but breaks Python 3. Local modules that have the same absolute module path as standard library modules will cause problems in either version of Python. I think it's unfortunate that Python files that happen to live in the same directory as the main script automatically get treated as top-level modules that shadow the standard library. You're not the first person to be confused by this. It appears that the reason this works for you in Python 2 and not in Python 3 is because the linecache module doesn't import tokenize in Python 2, whereas it does in Python 3. If you had tried to import tokenize directly in Python 2 then I expect you'd have the same problem.