Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'skip:u 30': 0.07; 'urllib2': 0.07; 'data:': 0.09; 'logic': 0.09; 'scheme.': 0.09; 'python': 0.11; '2.7': 0.14; 'belongs': 0.16; 'splitting': 0.16; 'urllib': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'seems': 0.21; '>>>': 0.22; 'import': 0.22; '(in': 0.22; 'least': 0.26; 'supported': 0.26; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'fixed': 0.29; 'leave': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'code': 0.31; "skip:' 40": 0.31; 'open': 0.33; 'skip:u 20': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:data': 0.36; 'outstanding': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'central': 0.64; 'more': 0.64; 'mar': 0.68; 'default': 0.69; 'unusual': 0.74; '2014,': 0.84; 'residual': 0.84 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=KXwvim4P8aOHhhunoT5W/PNTCY8UT5H74HfzkdohB2I=; b=K8IL8tRK0jQSVz+FzDJczFCee3EmG/5P9WwSQj1BE6PneX1UV8hbHFmLRqMdQeWX1K +HO42nPFmuDwLogOqbNpV7D6ngW0a3EQtGpF7TLOpZVuNw2i0iG3wi6kQi+8qmSF2/kt CBF8/n9RhzK/gD3VUSIuzIzJfDCkca9Pq9KOmyzbSjSpubSMrEsGHteXL22U5H7ZQPNH kFTtVHO7yf9eW5R2XWmfNqaNwxmOcZW8tVw/UOTFCuchciguK44qEURAIXr1qxSS/gs3 h42ocXikEIvzZpaQ3iGiMyM2QRZ65sXoHOOQt+8YKRjYZ5NSfpUwozLss1JNlTIri8YT EFxA== X-Received: by 10.66.160.34 with SMTP id xh2mr2530154pab.109.1399522680737; Wed, 07 May 2014 21:18:00 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <536A0E10.5030402@chamonix.reportlab.co.uk> References: <536A0E10.5030402@chamonix.reportlab.co.uk> From: Ian Kelly Date: Wed, 7 May 2014 22:17:20 -0600 Subject: Re: data: protocol 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399522689 news.xs4all.nl 2923 [2001:888:2000:d::a6]:45615 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71076 On Wed, May 7, 2014 at 4:42 AM, Robin Becker wrote: > I have an outstanding request for ReportLab to allow images to be opened > using the data: scheme. That used to be supported in python 2.7 using > urllib, but in python 3.3 urllib2 --> urllib and at least the default > urlopener doesn't support data: > > Is there a way to use the residual legacy of the old urllib code that's now > in urllib.URLopener to open unusual schemes? I know it can be used directly > eg > > urllib.request.URLopener().open('data:.........') > > but that seems to leave the splitting & testing logic up to me when it > logically belongs in some central place ie urllib.request.urlopen. Seems to be fixed in Python 3.4: Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib.request >>> url = 'data:text/plain;charset=UTF-8,Hello%20World' >>> urllib.request.urlopen(url).read() b'Hello World'